Change Elements
products = ["A", "B", "C"] products[2] = "D"
This changes the value of the element with the list number two (remember, arrays start counting at zero, so the element with the list number two is actually the third element.) As we changed "C" to "D", the array now contains "A", "B" and "D".
Add Elements
products = ["A", "B", "C"] products[3] = "D"
Now, the array has four elements: "A", "B", "C" and "D".
It is not necessary to know the array length to add an element at the end. In order to do it, the add ([]) operator or the extend method can be used.
products = ["A", "B", "C"] extend products // add at the end using "D"
Delete Elements
products = ["A", "B", "C"] delete products[0] // delete first elementNow, the array has two elements "B", "C".
Find Elements
products = ["A", "B", "C"] if "A" in products then display "'products' contains the element 'A'" end
products = ["A", "B", "A", "C"] index = indexOf(products, "A") if index != -1 then display "'A' is located at position : " + index end
products = ["A", "B", "A", "C"] index = lastIndexOf(products, "A") if index != -1 then display "'A' is located at position : " + index end