Kebab file names

This commit is contained in:
Angelos Chalaris
2023-04-27 21:58:35 +03:00
parent 1d189c709a
commit 61200d90c4
440 changed files with 0 additions and 0 deletions

21
snippets/all-equal.md Normal file
View File

@ -0,0 +1,21 @@
---
title: Check if array elements are equal
tags: array
cover: shelf-plant
firstSeen: 2018-08-03T00:03:08+03:00
lastUpdated: 2020-10-18T20:24:28+03:00
---
Checks 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.
- Elements in the array are compared using the strict comparison operator, which does not account for `NaN` self-inequality.
```js
const allEqual = arr => arr.every(val => val === arr[0]);
```
```js
allEqual([1, 2, 3, 4, 5, 6]); // false
allEqual([1, 1, 1, 1]); // true
```