<script>
let oldList = [{name:'ZhangSan',age:18},{name:'LiSi',age:20}]
let newList = oldList.map(i=> {
return {name:i.name,size:i.age,sex:'man'}
})
// 名字不變 age變成size 再加個sex都為man
console.log(oldList)
console.log(newList)
</script>
2.es6解構(gòu)
<script>
let {length : len1} = 'hello'; // len1 = 5
let x = 1
let y = 2;
//es6解構(gòu) x y 交換值
[x, y] = [y, x]
console.log('x=',x)
console.log('y=',y)
</script>