ES6: Use Destructuring Assignment to Assign Variables from Objects (FCC Beta)

So strings, when you do anything to them in JavaScript, get put in an object (the String object). That object has some properties, one of which is length. This challenge is asking you to pull out that property. So

const { length: len } = "foo";

Is basically saying "from the string object that represents the string 'foo', grab the length property and call it len"

It’s…a confusing challenge

As pointed out, it is the same as

const len = 'foo'.length
15 Likes