<body> <script type="text/javascript"> let arr1 = [1, 3, 5, 7, 9] let arr2 = [2, 4, 6, 8, 10] console.log(...arr1); let arr3 = [...arr1, ...arr2]
function sum(...numbers) { return numbers.reduce((preValue, currentValue) => { return preValue + currentValue }) }
console.log(sum(1, 2, 3, 4));
let person = { name: 'tom', age: 18 } let person2 = { ...person } person.name = 'jerry' console.log(person2); console.log(person);
let person3 = { ...person, name: 'jack', address: "地球" } console.log(person3); </script> </body>
|