Created
June 28, 2016 23:45
-
-
Save fijiwebdesign/b25bf2003bd25fa39db0164f913671df to your computer and use it in GitHub Desktop.
JS local object properties test
This file contains hidden or 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
// test local and inherited properties of an object | |
var obj = { name: 'test' }; | |
console.log(obj.name); // 'test' | |
console.log(obj.hasOwnProperty('name')); // true | |
obj.__proto__.age = 10000; // hack to make age an inherited property | |
console.log(obj.age); // 10000 | |
console.log(obj.hasOwnProperty('age')); // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment