Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get the first element in an array in javascript

var first = "role";
data.sort(function(x,y){ return x == first ? -1 : y == first ? 1 : 0; });
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #element #array #javascript
ADD COMMENT
Topic
Name
2+4 =