how to remove the elements from array and how to replace a new element in javascript
Array.splice(position,0,new_element_1,new_element_2,...);Code language: JavaScript (javascript)
0
0
let colors = ['red', 'green', 'blue'];Code language: JavaScript (javascript)
Thank you!
0
0
3.75
9
console.log(scores); // [4, 5]Code language: JavaScript (javascript)
Thank you!
9
0
0
0
let deletedScores = scores.splice(0, 3);Code language: JavaScript (javascript)
Thank you!
0
0
3.8
10
console.log(deletedScores); // [1, 2, 3]Code language: JavaScript (javascript)
Thank you!
10
0
5
1
let scores = [1, 2, 3, 4, 5];Code language: JavaScript (javascript)
Thank you!
1
0
Are there any code examples left?
New code examples in category Javascript