Skip to content

Instantly share code, notes, and snippets.

View toddmantell's full-sized avatar

Todd Mantell toddmantell

View GitHub Profile
@toddmantell
toddmantell / prototypes.js
Created January 13, 2017 14:57
Some examples to facilitate better understanding of the JS Prototypal Inheritance System
//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);
@toddmantell
toddmantell / Object.freeze-examples.js
Last active January 13, 2017 14:58
Simple example of using JS Object.freeze() function
//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';