freeCodeCamp/guide/english/certifications/javascript-algorithms-and-d.../es6/use-destructuring-assignmen.../index.md

854 B

title
Use Destructuring Assignment to Assign Variables from Objects

Use Destructuring Assignment to Assign Variables from Objects

This challenge requires some intuition about string objects in javascript.

When you create a string object it is based on the following string prototype.

Thus, each string has a length property; genericString = {length: 13}. (This is the only adopted property from the String.prototype.)

Reassign properties using deconstruction.

var basicOjb = {x: 40};
//To reassign 'get the value of the x property of basicObj and place its value into bigX' in ES6:
const { x: bigX } = basicOjb;
consle.log(bigX) // ans = 40 

Place the value of the length property of 'str' into len.