JavaScript

includes, some & every

Në shqip përdoret i njëjti emër.

ShpjegimiSQ

includes(x) kontrollon nëse vargu ka një vlerë; some(fn) nëse të paktën një element plotëson kushtin; every(fn) nëse të gjithë e plotësojnë. Të tria kthejnë true/false.

EnglishEN

includes(x) checks whether the array has a value; some(fn) whether at least one item meets the condition; every(fn) whether all do. All three return true/false.

Si ta mendosh

Si pyetjet „a ka dikush biletë?“ dhe „a kanë të gjithë biletë?“.

Lexoje në anglisht

Like asking “does anyone have a ticket?” versus “does everyone have a ticket?”.

Shembull kodijavascript

const notat = [5, 8, 9];
notat.includes(8);            // true
notat.some(n => n < 5);       // false
notat.every(n => n >= 5);     // true

Terma të lidhur