Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

remove string from array in js

// if you want to remove ALL occurences
let arr = ['A', 'B', 'C'];
arr = arr.filter(e => e !== 'B'); // will return ['A', 'C']

// if you want to remove ONLY 1st occurence
t = ['A', 'B', 'C', 'B'];
t.splice(t.indexOf('B'), 1); // will return ['B'] and t is now equal to ['A', 'C', 'B']
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #string #array #js
ADD COMMENT
Topic
Name
1+6 =