February 2018
Intermediate to advanced
298 pages
8h 22m
English
An object destructuring assignment is used to the extract property values of an object and assign them to the variables.
This is a traditional (and still useful) way of assigning property values to an object:
var object = {"name" : "John", "age" : 23};
var name = object.name;
var age = object.age;
We can do this in a one-line statement, using the object destructuring assignment:
let object = {"name" : "John", "age" : 23}; let name, age; ({name, age} = object); //object destructuring assignment syntax
On the left-hand side of the object destructuring statement, we need to place the variables to which we want to assign the object property values using a syntax similar to that of an object literal. On ...
Read now
Unlock full access