-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_of_form.js
More file actions
34 lines (24 loc) · 744 Bytes
/
array_of_form.js
File metadata and controls
34 lines (24 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//! array.some
const number = [1, 2, 3, 4, 5, 6, 7, 8, 9];
//? has odd number
const hasEvenNumber = number.some((n) => n % 2 == 0);
// console.log(hasEvenNumber);
const currentUserRole = ["user", "editor"];
const featureAccessRole = ["admin", "editor"];
const canAccess = currentUserRole.some((role) =>
featureAccessRole.includes(role),
);
// console.log(canAccess);
//! array.from
const arr = Array.from({ length: 5 }, (_, i) => i);
// arr.push("Hello");
// arr.unshift("Nothing");
// arr.unshift("More nothing");
arr.shift("More nothing");
// console.log(arr);
const range = (start, stop, step) =>
Array.from(
{ length: Math.ceil((stop - start) / step) },
(_, i) => start + i * step,
);
console.log(range(5, 11, 1));