0

exampleArray.push("this is an item");

I a thing. But there are also 10 other items within.
So I never truly know where that item is (which enumeration).

Is there a way of saying

exampleArray.delete("this is an item"); where it will remove item with "that" content?

(JavaScript question)

Edited by Aeonix

2
Contributors
1
Reply
18
Views
9 Months
Discussion Span
Last Post by diafol
1
var i = exampleArray.indexOf( valueToCheck );
if( i != -1 ) exampleArray.splice(i, 1);

Should remove your value from exampleArray. You can however create a prototype function, e.g.

Array.prototype.remVal = function(){
    //place code here
}

The in code...

exampleArray.remVal( valueToRemove );

Extending the Array prototype can cause collisions with frameworks, so ensure that you choose a unique function name.

Votes + Comments
Yep, that's about it, I wonder why it's not included
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.