JAVASCRIPT   23

in_array.js

Guest on 23rd August 2021 04:46:44 PM

  1. /**<dependency>[in_array]</dependency>**/
  2. function in_array (needle, haystack, argStrict)
  3. {
  4.   var key = '';
  5.   var strict = !!argStrict;
  6.  
  7.   if (strict) {
  8.     for (key in haystack) {
  9.       if (haystack[key] === needle) {
  10.         return true;
  11.       }
  12.     }
  13.   } else {
  14.     for (key in haystack) {
  15.       if (haystack[key] == needle) {
  16.         return true;
  17.       }
  18.     }
  19.   }
  20.  
  21.   return false;
  22. };

Raw Paste


Login or Register to edit or fork this paste. It's free.