Skip to content

Instantly share code, notes, and snippets.

@niyazpk
Created December 11, 2011 14:52
Show Gist options
  • Save niyazpk/1460963 to your computer and use it in GitHub Desktop.
Save niyazpk/1460963 to your computer and use it in GitHub Desktop.
// An easy fix would be:
for (name in object){
if (object.hasOwnProperty(name)){
// do stuff
}
}
// The above will fail if the object has a hasOwnProperty property.
// To Fix that, we write:
for (name in object){
if (object.prototype.hasOwnProperty.call(object, name)){
// do stuff
}
}
// aweful
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment