Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to check all values of an array are equal or not in javascript

// how to check all values of an array are equal or not in javascript
const allEqual = (arr) => arr.every(val => val === arr[0]);
console.log(allEqual([1, 2, 3, 4, 5, 6])); // false
console.log(allEqual([1, 1, 1, 1])); // true
Comment

check if all array elements are equal


function myFunction( arr ) {
  return new Set(arr).size === 1
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: paypal in react js 
Javascript :: build json object 
Javascript :: what is the use of useparams in react 
Javascript :: vue js qr code scanner 
Javascript :: custom search filter in angular 8 
Javascript :: javascript Iterate Through Iterables 
Javascript :: Kendo Grid export to Excel not working with large data 
Javascript :: elasticsearch response format 
Javascript :: crud in nodejs sequilize 
Javascript :: p5.js radians 
Javascript :: call dynamic var name javascript 
Javascript :: vuejs nested v-for 
Javascript :: vanilla js select by class 
Javascript :: how to keep a child window always on top in electron js 
Javascript :: react node-sass 
Javascript :: clear ckeditor textarea jquery 
Javascript :: angular 12 features 
Javascript :: javascript string insensitive compare 
Javascript :: javascript check if url ends with slash 
Javascript :: Nuxt Use Nginx as reverse Proxy 
Javascript :: js split method 
Javascript :: find all even numbers javascript 
Javascript :: stale element reference: element is not attached to the page document 
Javascript :: angular pipe paramerte 
Javascript :: angular inject token 
Javascript :: filter in javascript practice exercise 
Javascript :: javascript append list to list 
Javascript :: Vue Chartjs label false 
Javascript :: multiple image upload react 
Javascript :: unexpected token w in json at position 0 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =