let {toString: s} = 123; console.log(s) // ƒ toString() { [native code] }
- If the right of the equal sign is a numerical and Boolean values, it will first turn objects.
let {toString: s} = false; console.log(s) // ƒ toString() { [native code] }
-
undefined
Andnull
can not be converted to objects
let { prop: x } = undefined; let { prop: y } = null; console.log(x) // TypeError console.log(y) // TypeError