Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

PREVIOUS NEXT
Code Example
Javascript :: find an object in an array of objects javascript 
Javascript :: refresh page scrolltop 0 
Javascript :: reactjs add border to the table row 
Javascript :: jquery change value 
Javascript :: how to get the min value of two variables in math 
Javascript :: jest check array of string 
Javascript :: regrex for password 
Javascript :: how to remove duplicates from array in javascript 
Javascript :: how to print two arrays side by side in javascript 
Javascript :: faker.js lorem 
Javascript :: match date regex 
Javascript :: js remove from array by value 
Javascript :: how to loop through an object using lodash 
Javascript :: disable server side rendering next.js 
Javascript :: json server npm 
Javascript :: handling scrolling on react router transitions 
Javascript :: how to change react icon color 
Javascript :: how to get os information nodejs 
Javascript :: js addeventlistener to width of window 
Javascript :: sorting number with coma datatable 
Javascript :: access laravel eloquent relation in js 
Javascript :: Ready check failed: NOAUTH Authentication required. 
Javascript :: axios pass params 
Javascript :: jquery trigger link click 
Javascript :: get timezone javascript 
Javascript :: redirect react js 
Javascript :: react form on submit 
Javascript :: browserrouter react 
Javascript :: clear canvas 
Javascript :: xml to json api in asp.net 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =