访问数组的位置,并更改它,如下所示:
var arr = [1, 2, 3, 4, 5]; arr[0] = 6; // Now, the array is [6, 2, 3, 4, 5] arr[4] = 10 // Now, the array is [6, 2, 3, 4, 10]
这里重要的概念是数组是可变的 。这意味着它们可以轻松更改。