Last active
August 29, 2015 14:04
-
-
Save hoto/8d2dbe347405beb54d17 to your computer and use it in GitHub Desktop.
Iterating over object literals in javascript using for in
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
var objectLiteral = { | |
name: 'bilbo', | |
surname: 'bagins' | |
}; | |
for(var key in objectLiteral){ | |
if(objectLiteral.hasOwnProperty(key)){ | |
console.log('key: ' + key); | |
console.log('value: ' + objectLiteral[key]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment