![]() If the second argument is omitted, all elements from the start to the end of the array are removed. The splice() method returns an array of the deleted elements, or an empty array if no elements were deleted, as you can see in the above example. Removed = colors.splice(1, 1, "Purple", "Voilet") // Insert two values, remove oneĭocument.write(colors) //Prints: Green,Purple,Voilet,Yellow,Blueĭocument.write(removed) // Prints: Pink (one item array) Removed = colors.splice(1, 0, "Pink", "Yellow") // Insert two items at position oneĭocument.write(colors) // Prints: Green,Pink,Yellow,Blueĭocument.write(removed.length) // Prints: 0 Var removed = colors.splice(0,1) // Remove the first elementĭocument.write(colors) // Prints: Green,Blueĭocument.write(removed) // Prints: Red (one item array)ĭocument.write(removed.length) // Prints: 1
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |