@ -3,6 +3,7 @@
|
|||||||
Check if all elements in an array are equal.
|
Check if all elements in an array are equal.
|
||||||
|
|
||||||
Use `Array.prototype.every()` to check if all the elements of the array are the same as the first one.
|
Use `Array.prototype.every()` to check if all the elements of the array are the same as the first one.
|
||||||
|
Elements in the array are compared using the strict comparison operator, which does not account for `NaN` self-inequality.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const allEqual = arr => arr.every(val => val === arr[0]);
|
const allEqual = arr => arr.every(val => val === arr[0]);
|
||||||
|
|||||||
Reference in New Issue
Block a user