| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | [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 2022 8.
Array findLast() . undefined .
find() .findLastIndex() .indexOf() .
(findIndex() , .)includes() .
.some() .const array1 = [5, 12, 50, 130, 44];
const found = array1.findLast((element) => element > 45);
console.log(found);
// Expected output: 130
findLast(callbackFn)
findLast(callbackFn, thisArg)
( ) . undefined .
findlast() . callbackFn , callbackFn . findlast() . callbackFn , findlast() undefined . .
.
const inventory = [
{ name: "apples", quantity: 2 },
{ name: "bananas", quantity: 0 },
{ name: "fish", quantity: 1 },
{ name: "cherries", quantity: 5 },
];
// inventory true .
function isNotEnough(item) {
return item.quantity < 2;
}
console.log(inventory.findLast(isNotEnough));
// { name: "fish", quantity: 1 }
const inventory = [
{ name: "apples", quantity: 2 },
{ name: "bananas", quantity: 0 },
{ name: "fish", quantity: 1 },
{ name: "cherries", quantity: 5 },
];
const result = inventory.findLast(({ quantity }) => quantity < 2);
console.log(result);
// { name: "fish", quantity: 1 }
, undefined .
function isPrime(element) {
if (element % 2 === 0 || element < 2) {
return false;
}
for (let factor = 3; factor <= Math.sqrt(element); factor += 2) {
if (element % factor === 0) {
return false;
}
}
return true;
}
console.log([4, 6, 8, 12].findLast(isPrime)); // undefined,
console.log([4, 5, 7, 8, 9, 11, 12].findLast(isPrime)); // 11
array , . filter() findLast() .
const numbers = [3, -1, 1, 4, 1, 5, 9, 2, 6];
const lastTrough = numbers
.filter((num) => num > 0)
.findLast((num, idx, arr) => {
// arr
// .
if (idx > 0 && num >= arr[idx - 1]) return false;
if (idx < arr.length - 1 && num >= arr[idx + 1]) return false;
return true;
});
console.log(lastTrough); // 2
, undefined .
// 2, 3, 4
const array = [0, 1, , , , 5, 6];
// .
array.findLast((value, index) => {
console.log(` : ${index} : ${value}`);
});
// : 6 : 6
// : 5 : 5
// : 4 : undefined
// : 3 : undefined
// : 2 : undefined
// : 1 : 1
// : 0 : 0
// .
array.findLast((value, index) => {
// 5
if (index === 6) {
console.log(` ${array[5]} array[5] `);
delete array[5];
}
// 5 .
console.log(` : ${index} : ${value}`);
});
// 5 array[5]
// : 6 : 6
// : 5 : undefined
// : 4 : undefined
// : 3 : undefined
// : 2 : undefined
// : 1 : 1
// : 0 : 0
findlast() this length length .
const arrayLike = {
length: 3,
0: 2,
1: 7.3,
2: 4,
3: 3, // length 3 findlast() .
};
console.log(
Array.prototype.findLast.call(arrayLike, (x) => Number.isInteger(x)),
); // 4
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-array.prototype.findlast |
core-js Array.prototype.findLast ArrayArray.prototype.find()Array.prototype.findIndex()Array.prototype.findLastIndex()Array.prototype.includes()Array.prototype.filter()Array.prototype.every()Array.prototype.some()TypedArray.prototype.findLast()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 |