Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JavaScript Array Methods .splice()

// elem törlése
let myArray = ['a', 'b', 'c', 'd']
// 0. indextől számolva 2 elemet távolít el
myArray.splice(0, 2)
console.log(myArray)
// --> [ 'c', 'd' ]

// beszúrás
const months = ['Jan', 'March', 'April', 'June'];
// az 1-es indexű helyre illeszt be:
months.splice(1, 0, 'Feb');
console.log(months);
// --> ['Jan', 'Feb', 'March', 'April', 'June']
Source by github.com #
 
PREVIOUS NEXT
Tagged: #JavaScript #Array #Methods
ADD COMMENT
Topic
Name
4+4 =