| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/every | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.
Array every() false . true .
const isBelowThreshold = (currentValue) => currentValue < 40;
const array1 = [1, 30, 39, 29, 10, 13];
console.log(array1.every(isBelowThreshold));
// : true
every(callbackFn)
every(callbackFn, thisArg)
every() . callbackFn , callbackFn . every() false . callbackFn , every() true .
every " ~ (for all)" . true . ( .)
every() , callbackFn . length callbackFn . ,
: ( ).
9 .
function isBigEnough(element, index, array) {
return element >= 10;
}
[12, 5, 8, 130, 44].every(isBigEnough); // false
[12, 54, 18, 130, 44].every(isBigEnough); // true
.
const isSubset = (array1, array2) =>
array2.every((element) => array1.includes(element));
console.log(isSubset([1, 2, 3, 4, 5, 6, 7], [5, 7, 6])); // true
console.log(isSubset([1, 2, 3, 4, 5, 6, 7], [5, 8, 7])); // false
every() .
console.log([1, , 3].every((x) => x !== undefined)); // true
console.log([2, , 2].every((x) => x === 2)); // true
every .
// ---------
//
// ---------
let arr = [1, 2, 3, 4];
arr.every((elem, index, arr) => {
arr[index + 1]--;
console.log(`[${arr}][${index}] -> ${elem}`);
return elem < 2;
});
// 3 ,
// 2 .
//
// : [1,1,3,4][0] -> 1
// : [1,1,2,4][1] -> 1
// : [1,1,2,3][2] -> 2
// ---------
//
// ---------
arr = [1, 2, 3];
arr.every((elem, index, arr) => {
arr.push("new");
console.log(`[${arr}][${index}] -> ${elem}`);
return elem < 4;
});
// 3 .
//
// : [1, 2, 3, new][0] -> 1
// : [1, 2, 3, new, new][1] -> 2
// : [1, 2, 3, new, new, new][2] -> 3
// ---------
//
// ---------
arr = [1, 2, 3, 4];
arr.every((elem, index, arr) => {
arr.pop();
console.log(`[${arr}][${index}] -> ${elem}`);
return elem < 4;
});
// `pop()` 2 .
//
// : [1,2,3][0] -> 1
// : [1,2][1] -> 2
every() this length , length callbackFn false .
const arrayLike = {
length: 3,
0: "a",
1: "b",
2: "c",
3: 345, // length 3 every() .
};
console.log(
Array.prototype.every.call(arrayLike, (x) => typeof x === "string"),
); // true
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-array.prototype.every |
core-js Array.prototype.every ArrayArray.prototype.forEach()Array.prototype.some()Array.prototype.find()TypedArray.prototype.every()This page was last modified on 2025 10 10 by MDN contributors.
Arrayat()concat()copyWithin()entries()every()fill()filter()find()findIndex()findLast()findLastIndex()flat()flatMap()forEach()includes()indexOf()join()keys()lastIndexOf()map()pop()push()reduce()reduceRight()reverse()shift()slice()some()sort()splice()toLocaleString()toReversed()toSorted()toSpliced()toString()unshift()values()with()[Symbol.iterator]()Object/FunctionObject.prototype.__defineGetter__()Object.prototype.__defineSetter__()Object.prototype.__lookupGetter__()Object.prototype.__lookupSetter__()Object.prototype.hasOwnProperty()Object.prototype.isPrototypeOf()Object.prototype.propertyIsEnumerable()Object.prototype.toLocaleString()Object.prototype.toString()Object.prototype.valueOf()Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |