Skip to content

Instantly share code, notes, and snippets.

@alexnm
Last active March 27, 2016 16:41
Show Gist options
  • Save alexnm/606c02e9806b75f3042f to your computer and use it in GitHub Desktop.
Save alexnm/606c02e9806b75f3042f to your computer and use it in GitHub Desktop.
Example of object creation through object literal
const product = {
name: 'T-Shirt',
price: 9.99,
color: 'red',
size: 'M',
stock: 4,
updateStock: function( newStock ) {
this.stock += newStock;
}
};
console.log( product.stock ); // 4
product.updateStock( 3 );
console.log( product.stock ); // 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment