Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
const a = [1, 2, 3]; const b = [4, 5, 6]; const merged = [...a, ...b]; console.log(merged); // [1,2,3,4,5,6] const copy = [...a]; copy.push(99); console.log(a); // [1,2,3] — untouched console.log(copy); // [1,2,3,99] function sum(...nums) { return nums.reduce((acc, n) => acc + n, 0); } console.log(sum(1, 2, 3, 4)); // 10 const nums = [3, 1, 4, 1, 5]; console.log(Math.max(...nums)); // 5
Result
Open