js数组添加元素方法

在JavaScript中,有几种方法可以向数组中添加元素:
- 使用push()方法:push()方法将一个或多个元素添加到数组的末尾,并返回新数组的长度。例如:
let array = [1, 2, 3];
array.push(4);
console.log(array); // 输出:[1, 2, 3, 4]
22
0
2025-03-03
javascript技巧