replace if array has data or not js code example
Example 1: replace array element javascript stack overflow
var index = items.indexOf(3452);
if (index !== -1) {
items[index] = 1010;
}
Example 2: replace array element javascript stack overflow
if (haystack.includes(needle)) {
// do your thing
}