Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

delete element from array js

// Create a function to do it easily and how many time you want!
const deleteFromArray = (array, value) => {
  let newArray = array.filter(item => item !== value)
  return newArray;
}

var array = [1, 2, 3, 4]
const newArr = deleteFromArray(array, 2)
console.log('Changed array:', newArr);
// Changed array: [ 1, 3, 4 ]
Source by love2dev.com #
 
PREVIOUS NEXT
Tagged: #delete #element #array #js
ADD COMMENT
Topic
Name
6+7 =