质量为本、客户为根、勇于拼搏、务实创新
怎样在pel数组中添加新的元素
要在pel数组中添加新元素,可使用JavaScript中的push()方法。例如:
let pel = [1, 2, 3, 4]; pel.push(5); console.log(pel); // Output: [1, 2, 3, 4, 5]
在上面的例子中,我们使用push()方法将数字5添加到pel数组中。您可以将任何值添加到数组中,包括数字,字符串,对象等。
TOP