Last active
February 23, 2017 08:13
-
-
Save manojsinghnegiwd/df7b45a24796fedf36b20d4c1c599274 to your computer and use it in GitHub Desktop.
Get first element of an object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getFirst (obj) { | |
var first = null; | |
for(var prop in obj) { | |
first = obj[prop]; | |
break; | |
} | |
return first; | |
} | |
var obj = { | |
name: 'obj', | |
length: '1' | |
} | |
var fst = getFirst(obj); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment