Skip to content

Instantly share code, notes, and snippets.

@dpedro
Last active August 10, 2016 15:07
Show Gist options
  • Save dpedro/274d6b4c5ed01004b734710e6958077e to your computer and use it in GitHub Desktop.
Save dpedro/274d6b4c5ed01004b734710e6958077e to your computer and use it in GitHub Desktop.
Object by key, value
var users = {}
users = {
"john": { id: 'john01', role: 'admin' },
"bob": { id: 'bob01', role: 'reader' },
}
users["steeve"] = { id: 'steeve01', role: 'admin' };
console.log(users);
console.log(users['bob']);
console.log(Object.keys(users).length)
Object.keys(users).map(function(user, index) {
console.log(user);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment