![]() ![]() The following figure demonstrates the method call above. console.log(colors) // Code language: JavaScript ( javascript ) The colors array now has four elements with the new element inserted in the second position. colors.splice( 2, 0, 'purple') Code language: JavaScript ( javascript ) The following statement inserts one element after the second element. let colors = Code language: JavaScript ( javascript ) Also, the splice() method does not remove any elements, therefore, it returns an empty array. For example:Īssuming that you have an array named colors with three strings. Note that the splice() method actually changes the original array.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |