JavaScript Array Type

Modification

We can replace an element at an index using the same syntax as when we extracted elements using their index.

identifier[index] = anotherElement

If we specify and index outside of the array's bounds, the array will expand to a length such that the newly given index is that last element. All elements between the previous last element and the new one will be undefined.

Code example

const quote = [
"I",
"write",
"these",
"words",
"in",
"steel,",
"for",
"anything",
"not",
"set",
"in",
"metal",
"cannot",
"be",
"trusted.",
]
quote[5] = "wood,"
quote[11] = "wood"