This question already has an answer here:
- array.contains(obj) in JavaScript 23 answers
I have this two arrays.
url = ["http://www.linkedin.com/in/jannuelanarna", "http://www.linkedin.com/in/jannuela", undefined, undefined];
publicUrl = ["http://www.linkedin.com/in/jannuelanarna", "http://www.linkedin.com/pub/jay-r-bautista/64/b29/45b", undefined, "http://www.linkedin.com/pub/ronilo-canson/75/927/4a3", "http://www.linkedin.com/pub/siddharth-chaudhary/33/aa1/8", "http://www.linkedin.com/in/rojohnh", "http://www.linkedin.com/pub/lara-martinez/74/777/a3b", "http://www.linkedin.com/pub/alena-ortega/69/72a/415", "http://www.linkedin.com/in/nivlek1416", "http://www.linkedin.com/pub/emmar-reveriza/59/a91/132", "http://www.linkedin.com/in/samsanchezcb", "http://www.linkedin.com/pub/mitch-stevens/6b/375/3a0", "http://www.linkedin.com/pub/irish-jane-sumadic/29/339/910", "http://www.linkedin.com/pub/joel-sumadic/45/31b/ab3", "http://www.linkedin.com/pub/luna-cielo-yniesta/68/4b2/690"];
What will be the code so that I could search if a url exist in an array?
url.indexOf('http://www.linkedin.com/in/jannuelanarna')
? (Should return0
I think) – Dave Chen Sep 9 '13 at 21:36indexOf
. You can either check one array at a time, or concatenate the arrays and check the resulting array. – bfavaretto Sep 9 '13 at 21:43