javascript in_array

/ Published in: JavaScript
Save to your folder(s)

Quick and easy javascript in_array function. It's not perfect, but if you need something quick, this is it.

Copy this code and paste it in your HTML
  1. function in_array(needle, haystack) {
  2. for (var i=0, j=haystack.length; i < j; i++) {
  3. if (needle == haystack[i]) return true;
  4. }
  5. return false;
  6. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.