Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find array in js

function include(arr, obj) {
  for (var i = 0; i < arr.length; i++) {
    if (arr[i] == obj) return true;
  }
}

console.log(include([1, 2, 3, 4], 3)); // true
console.log(include([1, 2, 3, 4], 6)); // undefined
 Run code snippet
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #array #js
ADD COMMENT
Topic
Name
6+4 =