Deconstruction assignment - Numerical and Boolean values deconstruction assignment

       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] }
  •   undefinedAnd nullcan not be converted to objects
        let { prop: x } = undefined; 
        let { prop: y } = null; 
        console.log(x) // TypeError
        console.log(y) // TypeError

  

Guess you like

Origin www.cnblogs.com/blogZhao/p/12553661.html