Lesson 20 of 55
javascriptObject Literals, Shorthand & Destructuring
10 mins
Course progress36%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 20 of 55
javascript10 mins
Keep these ideas in mind as you work through the lesson.
Object literal shorthand:
const name = 'John';
const user = { name, age:30, greet(){ console.log('hi'); } };
Destructuring makes extracting values easy:
const {name, age} = user;
const [first, second] = [10,20];
Nested destructuring:
const {address:{city}} = user;
function render({title, content, author='Anonymous'} = {}){
console.log(title, content, author);
}
render({title:'Demo', content:'Hello'});