The doc page for destructuring assignment says
This means if you try to destruct a primitive value, the value will
get wrapped into the corresponding wrapper object and the property is
accessed on the wrapper object.
Does this mean the following code?:
const { a, toFixed } = 1;
Is equivalent to:
const { a, toFixed } = {1};
>Solution :
No, it means that your 1 is turned into a Number instance, and then the destructuring acts on that.
So it’s like
const { a, toFixed } = new Number(1);
The primitive value types number, string, and boolean all have corresponding wrapper types.