freeCodeCamp/guide/english/certifications/javascript-algorithms-and-d.../basic-javascript/modify-array-data-with-indexes/index.md

17 lines
521 B
Markdown
Raw Normal View History

2018-10-12 19:37:13 +00:00
---
title: Modify Array Data With Indexes
---
## Modify Array Data With Indexes
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
Access the position of the array, and change it, like so:
```javascript
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]
```
The important concept here is that arrays are **mutable**. This means that they can be changed easily.