Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
28
rated 0 times [  34] [ 6]  / answers: 1 / hits: 27949  / 12 Years ago, thu, june 7, 2012, 12:00:00

If I have array, for example:



a = [a, b, c]


I need something like



a.remove(a);


How can I do this?


More From » arrays

 Answers
1
var newArray = [];
var a=[a,b,c];
for(var i=0;i<a.length;i++)
if(a[i]!==a)
newArray.push(a[i]);


As of newer versions of JavaScript:



var a = [a,b,c];
var newArray = a.filter(e => e !== a);

[#85071] Thursday, June 7, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eden

Total Points: 730
Total Questions: 117
Total Answers: 117

Location: Peru
Member since Fri, Oct 14, 2022
2 Years ago
eden questions
;