From 3e39f23d4bd7d202d180bd1abf29ff0d2e18ecf0 Mon Sep 17 00:00:00 2001 From: Dym Sohin Date: Sun, 12 Jul 2020 05:56:45 +0200 Subject: [PATCH] use isArray instead of instanceof --- snippets/last.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/last.md b/snippets/last.md index efc48c99a..617fe8ffd 100644 --- a/snippets/last.md +++ b/snippets/last.md @@ -8,7 +8,7 @@ Returns the last element in an array. Check if `arr` is an instance of an `Array`, use `arr.length - 1` to compute the index of the last element of the given array and return it, otherwise return `undefined`. ```js -const last = arr => (arr instanceof Array ? arr[arr.length - 1] : undefined); +const last = arr => (Array.isArray(arr) ? arr[arr.length - 1] : undefined); ``` ```js