Answers for "js replace item in array at index"

2

js replace item in array at index

array.splice(indexWhereToReplace, 1, replacement)

// Ex
const arr = [1, 2, 3]
arr.splice(1, 1, 'replacement')
console.log(arr) // [1, 'replacement', 3]
Posted by: Guest on May-21-2021

Code answers related to "js replace item in array at index"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language