Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

remove an element from array

var colors = ["red", "blue", "car","green"];

// op1: with direct arrow function
colors = colors.filter(data => data != "car");

// op2: with function return value
colors = colors.filter(function(data) { return data != "car"});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #element #array
ADD COMMENT
Topic
Name
2+9 =