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
| //JavaScript Objects and Prototypes: Two ways of understanding prototypes | |
| //Constructor function | |
| function Cat(name, color) { | |
| this.name = name; | |
| this.color = color; | |
| //this.age = 7; | |
| } | |
| console.log(Cat.prototype); |
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
| //Examples of JS Object.freeze function (mdn: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) | |
| let o = { | |
| name: 'todd', | |
| age: 34, | |
| favoriteLanguage: 'JavaScript' | |
| }; | |
| Object.freeze(o); | |
| o.newProp = 'this should not get added'; |
NewerOlder