0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

「const {変数} = () => {」がわからない人へ

Posted at

はじめに

JavaScriptのコードを眺めているとよく現れる「const {変数} = () => {
なんとなく何かの処理が始まるまじないかなと思ってたので、今回かみ砕いてみました。

const

constは、変数を定義するために使用される修飾子です。
定義した変数は、その後のプログラム中で値を変更することはできなくなります。
同様の定数を定義する修飾子に「let」がありますが、こちらはプログラム中に変数の値を変更することができます。

=

=は、代入演算子です。
左辺にある変数に、右辺の値を代入するために使用されます。

() => {}

() => { は、JavaScriptのアロー関数を使用した定義方法です。
アロー関数とは、要するに簡潔に表現できる関数記述となり、JavaScriptで関数表記によく用いられるfunctionを使用した定義と同じ意味を持ちます。

※その他の特徴は以下参照
https://typescriptbook.jp/reference/functions/function-expression-vs-arrow-functions

最後に

簡潔に「const {変数} = () => {」をまとめてみました。
パッとみ暗号ですが、ひとつづ紐解いていくと何となく理解できるものですね。
この記事が誰かの学習の足掛かりになれば幸いです。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?