From ef642508203459ebdccdc147c8d36e430a2c0c19 Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Sun, 29 Sep 2019 12:29:54 -0600 Subject: [PATCH] Video 39 --- playground/5-es6-objects.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 playground/5-es6-objects.js diff --git a/playground/5-es6-objects.js b/playground/5-es6-objects.js new file mode 100644 index 0000000..c792f6d --- /dev/null +++ b/playground/5-es6-objects.js @@ -0,0 +1,36 @@ +// Object property shorthand + +const name = 'Jason' +const userAge = 38 + +const user = { + name, + age: userAge, + location: 'Calgary' +} + +console.log(user) + +// Object destructuring + +const product = { + label: 'Red notebook', + price: 3, + stock: 201, + salePrice: undefined, + rating: 4.2 +} + +// const label = product.label +// const stock = product.stock + +// const {label:productLabel, stock, rating = 5} = product +// console.log(productLabel) +// console.log(stock) +// console.log(rating) + +const transaction = (type, {label, stock}) => { + console.log(type, label, stock) +} + +transaction('order', product)