Skip to content

Instantly share code, notes, and snippets.

@codylindley
Created April 12, 2012 22:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codylindley/2371430 to your computer and use it in GitHub Desktop.
Save codylindley/2371430 to your computer and use it in GitHub Desktop.
//document own properties
console.log(Object.keys(document).sort());
//document own properties & inherited properties
var documentPropertiesIncludeInherited = [];
for(var p in document) { documentPropertiesIncludeInherited.push(p); }
console.log(documentPropertiesIncludeInherited.sort());
//document inherited properties only
var documentPropertiesOnlyInherited = [];
for(var p in document) {
if(!document.hasOwnProperty(p)){
documentPropertiesOnlyInherited.push(p);
}
}
console.log(documentPropertiesOnlyInherited.sort())
//document own properties & own non-enumerable
console.log(Object.getOwnPropertyNames(document).sort());
//document own non-enumerable
​console.log(_.difference(Object.getOwnPropertyNames(document),Object.keys(document)).sort());​
@snntaylan
Copy link

what is the meaning of "if(!document.hasOwnProperty(p)){" this line ? I could not understand ! (exclamation mark)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment