| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/includes | [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 2016 8.
Array includes() true false .
const array1 = [1, 2, 3];
console.log(array1.includes(2));
// Expected output: true
const pets = ["cat", "dog", "bat"];
console.log(pets.includes("cat"));
// Expected output: true
console.log(pets.includes("at"));
// Expected output: false
includes(searchElement)
includes(searchElement, fromIndex)
searchElement.
fromIndex OptionalfromIndex < 0, fromIndex + array.length . , .fromIndex < -array.length fromIndex , 0 .fromIndex >= array.length , false .( fromIndex , fromIndex ) searchElement true .
includes() SameValueZero searchElement . 0 . (, -0 0 ), false 0 . NaN .
[1, 2, 3].includes(2); // true
[1, 2, 3].includes(4); // false
[1, 2, 3].includes(3, 3); // false
[1, 2, 3].includes(3, -1); // true
[1, 2, NaN].includes(NaN); // true
["1", "2", "3"].includes(3); // false
fromIndex false . .
const arr = ["a", "b", "c"];
arr.includes("c", 3); // false
arr.includes("c", 100); // false
fromIndex , searchElement .
0 .
// 3
// fromIndex -100
// 3 + (-100) = -97
const arr = ["a", "b", "c"];
arr.includes("a", -100); // true
arr.includes("b", -100); // true
arr.includes("c", -100); // true
arr.includes("a", -2); // false
undefined true .
console.log([1, , 3].includes(undefined)); // true
includes() this length length .
const arrayLike = {
length: 3,
0: 2,
1: 3,
2: 4,
3: 1, // length 3 includes() .
};
console.log(Array.prototype.includes.call(arrayLike, 2));
// true
console.log(Array.prototype.includes.call(arrayLike, 1));
// false
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-array.prototype.includes |
core-js Array.prototype.includes ArrayArray.prototype.indexOf()Array.prototype.find()Array.prototype.findIndex()TypedArray.prototype.includes()String.prototype.includes()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 |