Skip to content

Instantly share code, notes, and snippets.

@marcusbesjes
Created July 3, 2015 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusbesjes/0a390c60c3bde8360c64 to your computer and use it in GitHub Desktop.
Save marcusbesjes/0a390c60c3bde8360c64 to your computer and use it in GitHub Desktop.
for var key in obj - keys out of order
var obj1 = {}
define(obj1, 'firstkey', {
get: function() {
return 'firstkey value'
},
enumerable: true
})
var Obj2 = function() {}
Obj2.prototype = obj1
var obj2 = new Obj2()
obj2.secondkey = 'should be last'
for(var k in obj2) {
console.log('key:', k, obj2[k])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment