Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Array.prototype.{findLast, findLastIndex}の追加 #1675

Merged
merged 21 commits into from
Jul 7, 2023
Merged

Conversation

azu
Copy link
Collaborator

@azu azu commented Jun 25, 2023

概要

ES2023では、Array.prototype.findIndexArray.prototype.find に対応するメソッドとして、
Array.prototype.findLastIndexArray.prototype.findLastが追加されました。

それぞれ indexOflastIndexOf と同様に、末尾から探索した結果を返すメソッドになっています。

変更されたページ

変更点

  • ES2023で追加された Array.prototype.findLastIndexArray.prototype.findLast の対応
  • Array.prototype.lastIndexOf のサンプルコードを追加

関連

@azu azu linked an issue Jun 25, 2023 that may be closed by this pull request
@bot-user
Copy link

bot-user commented Jun 25, 2023

Deploy Preview for js-primer ready!

Name Link
🔨 Latest commit 79bb287
🔍 Latest deploy log https://app.netlify.com/sites/js-primer/deploys/64a7a1c674a438000875a3bd
😎 Deploy Preview https://deploy-preview-1675--js-primer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -296,6 +302,8 @@ console.log(indexOfBlue); // => 2
console.log(colors[indexOfBlue]); // => { "color": "blue" }
```

Arrayの`findIndex`にも対となる`findLastIndex`メソッドがあり、`findLastIndex`メソッドは末尾から検索した結果が得られます。
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

サンプルコードを入れたい気もするが、なくても大丈夫という気もする。

一つ思いついたのは、最初に記録された日と最後に記録された日をfindとfindLastで探すという例。
これが何の記録かというのがいまいち思いつかなかった。
[{ date: "2023-06-01", count: 1},{ date: "2023-06-10", count: 10}, { date: "2023-06-25", count: 15}]

azu added 20 commits July 7, 2023 13:29
Signed-off-by: azu <azuciao@gmail.com>
Signed-off-by: azu <azuciao@gmail.com>
Signed-off-by: azu <azuciao@gmail.com>
Signed-off-by: azu <azuciao@gmail.com>
Signed-off-by: azu <azuciao@gmail.com>
Signed-off-by: azu <azuciao@gmail.com>
Signed-off-by: azu <azuciao@gmail.com>
Signed-off-by: azu <azuciao@gmail.com>
Signed-off-by: azu <azuciao@gmail.com>
Signed-off-by: azu <azuciao@gmail.com>
@azu azu changed the title feat: Array.prototype.findLastIndexの追加 feat: Array.prototype.{findLast, findLastIndex}の追加 Jul 7, 2023
@azu azu merged commit 448f8b2 into master Jul 7, 2023
@azu azu deleted the feature/1665 branch July 7, 2023 05:35
@azu azu added the Lang: ES2023 ECMAScript 2023 label Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ES2023: proposal-array-find-from-last
2 participants