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)

Member Avatar for diafol
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.

commented: Yep, that's about it, I wonder why it's not included +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.