Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JavaScript Splice

    let fruits = ["apple", "pear", "plum", "orange", "cherry"];
    fruits.splice(1, 0, 'watermelon');
    console.log(fruits);
    fruits.splice(1, 1);
    console.log(fruits)
    /*
    
[ 'apple', 'watermelon', 'pear', 'plum', 'orange', 'cherry' ]
[ 'apple', 'pear', 'plum', 'orange', 'cherry' ]
    
    */
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #JavaScript #Splice
ADD COMMENT
Topic
Name
2+6 =