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

js any array

 
// There's no isEmpty or any method. 
// You can define your own .isEmpty() or .any()

Array.prototype.isEmpty = function() {
    return this.length === 0;
}

Array.prototype.any = function(func) {
   return this.some(func || function(x) { return x });
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: unidirectional data flow react 
Javascript :: requestanimationframe 
Javascript :: how check if a form date is before today javascript 
Javascript :: how to change text color sweet alert IN JS 
Javascript :: react-native build debug apk 
Javascript :: javascript splice 
Javascript :: remove duplicates from array in javascript 
Javascript :: sum of array of number 
Javascript :: web3 js get network 
Javascript :: htpp code 
Javascript :: li dots 
Javascript :: angular animation scale width and height 
Javascript :: regex e-mail 
Javascript :: jquery input hidden value 
Javascript :: jquery datatable table header not increasing on expanding 
Javascript :: node.js name of file 
Javascript :: binary addition javascript 
Javascript :: javascript getdate 
Javascript :: vue custom events 
Javascript :: jquery console log 
Javascript :: javascript window 
Javascript :: drupal8 get params from route 
Javascript :: onfocus js 
Javascript :: ReactJS Axios Delete Request Code Example 
Javascript :: how to fetch first 10 characters of a string in node js 
Javascript :: material ui dark theme 
Javascript :: how to add element in arry in js 
Javascript :: jquerry get url 
Javascript :: how to replace empty string with undefined 
Javascript :: mongoose connect to atlas 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =