Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript array any

const array = [1, 2, 3, 4, 5];
// checks whether an element is even
const even = (element) => element % 2 === 0;
console.log(array.some(even));
// expected output: true
Comment

js any

// Use method "some" to loop through array elements and see if there are any matching ones
const array = [{ name: 'Dharmesh', gender: 'male' }, { name: 'Priti', gender: 'female' }];
const hasFemaleContender = array.some(({ gender }) => gender === 'female');
console.log(hasFemaleContender);
Comment

PREVIOUS NEXT
Code Example
Javascript :: forever.js 
Javascript :: javascript iterate over map values 
Javascript :: typescript get class list for element 
Javascript :: reverse individual words in a sentence javascript 
Javascript :: react native run real device 
Javascript :: react native swiper 
Javascript :: js array pop 
Javascript :: javascript check if array is empty or null or undefined 
Javascript :: nodejs set dns for request 
Javascript :: get selected option text jquery 
Javascript :: how to copy an arry react 
Javascript :: else statement 
Javascript :: background colour in react 
Javascript :: cloudinary react 
Javascript :: js foreach key value 
Javascript :: on hover display block jquery 
Javascript :: yup validation based on another field value 
Javascript :: javascript last character of a string 
Javascript :: jquery event methods 
Javascript :: detect form input changes javascript 
Javascript :: javascript string error 
Javascript :: javascript trim whitespace 
Javascript :: convert % to px javascript 
Javascript :: set time in javascript 
Javascript :: javascript window screen 
Javascript :: iframe url redirect 
Javascript :: manage nodejs versions on windows 
Javascript :: check empty object javascript 
Javascript :: create callback function javascript 
Javascript :: classlist remove multiple classes 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =