Assignment

Once you've accessed elements in an array, you can reassign them to new values. The assignment of array elements uses the same syntax as variable assignment. If you're feeling blasphemous, you can make your array of Game of Thrones characters include characters from another television show:

You can even assign elements to valueless array indices:

Note that assigning "Morty" to blasphemous_characters[blasphemous_characters.length] added an element to the end of the array (to an index that didn't have a value previously), thereby increasing the array's length by one.

results matching ""

    No results matching ""