-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathincludes-some.js
More file actions
26 lines (24 loc) · 1.19 KB
/
includes-some.js
File metadata and controls
26 lines (24 loc) · 1.19 KB
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
/* -------------------------------------------------------------------------- */
/* $Includes */
/* ---------------- sirve solo con arrays retorna un booleano --------------- */
/* -------------------------------------------------------------------------- */
const arrayIncludes = [1, 2, 3, 4, 5];
const isIncluded = arrayIncludes.includes(4);
console.log(isIncluded); /* true */
/* -------------------------------------------------------------------------- */
/* $Some */
/* ------ funciona para arrays y arrays de objetos retorna un booleano ------ */
/* -------------------------------------------------------------------------- */
const arraySome = [1, 2, 3, 4, 5];
const isSome = arraySome.some((element) => element === 4);
console.log(isSome); /* true */
/* ---------------------------- array de objetos ---------------------------- */
const arrayObjects = [
{ name: "Jhon", age: 21 },
{ name: "Camila", age: 22 },
{ name: "Kevin", age: 15 },
];
const isSomeObject = arrayObjects.some(
(elements) => elements.name === "Camila"
);
console.log(isSomeObject); /* true */