温馨提示×

如何在pel数组中添加新的元素

pel
小樊
82
2024-04-17 14:13:04
栏目: 编程语言

要在pel数组中添加新元素,可以使用JavaScript中的push()方法。例如:

let pel = [1, 2, 3, 4];

pel.push(5);

console.log(pel); // Output: [1, 2, 3, 4, 5]

在上面的例子中,我们使用push()方法将数字5添加到pel数组中。您可以将任何值添加到数组中,包括数字,字符串,对象等。

0