How is the object expansion operator in the es7 draft implemented?

The array expansion operator in

es6 is actually because the array is linear with the Symbol.iterator attribute. But the object doesn"t have an iterator interface, so how can you use the expansion operator? And. How on earth is the unfold operator implemented?

Dec.23,2021

https://babeljs.io/repl

let baseArr = [1,2,3]

let arr = [0,...baseArr,4];
//------------transform-------------------
var arr = [0].concat(baseArr, [4])[0];
let baseObj = {name:'a'};

let obj = {age:1,...baseObj,name:'b'}
//------------transform-------------------
var obj = _extends({ age: 1 }, baseObj, { name: 'b' });
Menu