We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 24b4933 commit efb99dbCopy full SHA for efb99db
src/utils/last.js
@@ -0,0 +1,5 @@
1
+export default function last(arrayLike) {
2
+ if (Array.isArray(arrayLike)) return arrayLike.at(-1);
3
+ if (arrayLike?.length !== undefined) return arrayLike[arrayLike.length - 1];
4
+ throw new Error('Not an array like object', typeof arrayLike);
5
+}
0 commit comments