Javascript array search -



Javascript array search -

whats best way search javascript array entry?? items strings.

is using lastindexof? so:

var list= []; list.push("one"); list.push("two"); list.push("three"); if(list.lastindexof(somestring) != -1) { alert("this nowadays in list"); return; }

is using lastindexof?

yes. however, i'd utilize simpler indexof() if don't need explicitly search backwards (which don't if test "does not contain"). notice these methods standardized in es5 , need shimmed in old browsers not back upwards them natively.

javascript

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -