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 array values equal js

[1,1,1,1].every( (val, i, arr) => val === arr[0] )   // true
Comment

js check if all array values are the same

const allEqual = arr => arr.every( v => v === arr[0] )
allEqual( [1,1,1,1] )  // true
Comment

PREVIOUS NEXT
Code Example
Javascript :: nodejs binary string to decimal number 
Javascript :: add onclick event jquery button 
Javascript :: how to push string into array in javascript 
Javascript :: js loop array in array 
Javascript :: js get element by attribute 
Javascript :: how to remove duplicates in array in javascript 
Javascript :: js pass object property as a function parameter 
Javascript :: joi validation 
Javascript :: apply eventlistener to iframe 
Javascript :: 0.1+0.2 javascript 
Javascript :: react-router-dom redirect 
Javascript :: include cookies in fetch 
Javascript :: react conditionally disable button 
Javascript :: isnan javascript 
Javascript :: jspdf pdf from html 
Javascript :: js sleep 
Javascript :: Fibonacci Recursive in js 
Javascript :: reactjs cdn 
Javascript :: readfile nodejs 
Javascript :: node mysql 
Javascript :: Cookies In NodeJS 
Javascript :: using dto in express 
Javascript :: onclick change image javascript example 
Javascript :: open bootstrap modal with javascript 
Javascript :: preload javascript 
Javascript :: node red http post request data 
Javascript :: number round 
Javascript :: create empty array javascript 
Javascript :: split string based on length in javascript 
Javascript :: javascript iterate object attribute name 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =