Each item of this array is some number.
var items = Array(523,3452,334,31, ...5346);
How do I replace some number in with array with a new on
Best way in just one line to replace or update item of array
array.splice(array.indexOf(valueToReplace), 1, newValue)
Eg:
let items = ['JS', 'PHP', 'RUBY'];
let replacedItem = items.splice(items.indexOf('RUBY'), 1, 'PYTHON')
console.log(replacedItem) //['RUBY']
console.log(items) //['JS', 'PHP', 'PYTHON']
An other simple way to do the same operation is :
items[items.indexOf(oldValue)] = newValue