概述 大家都知道ES6的解构,有时也会在解构的时候进行赋值默认值。 不过不知道大家是不是注意到,有时候的赋值是不生效的。 看个例子: const user = { name: 'xiaohesong', age: null, sex: ''} const { name, age = 18, sex = 'man', gf = 'lzl'} = user console.log(name, age