Spreading undefined in array vs object
问题 Why does spreading undefined in an object return an empty object? {...undefined} // equals {} : console.log({...undefined}) And Why does spreading undefined in an array give you an error? [...undefined] // type error : console.log([...undefined]) 回答1: As noted in the comments, and summarized by @ftor from #687, object spread is equivalent 1 to Object.assign() (issues #687, #45), where as spread in array literal context is iterable spread. Quoting Ecma-262 6.0, Object.assign() is defined as: