0
0

More than 3 years have passed since last update.

アロー関数を使わない記法

Last updated at Posted at 2021-06-28

アロー関数を使わない記法

今日勉強したことを記録に残しておこうと思って記事にしました。
CodeMafiaさんのUdemyのコースを受講しています。SassやCSSのアニメーション
Java ScriptなどProgate終わったあとにフロントエンドの勉強をしたいと思っている人には
最適なコースなのでおすすめです。


ご興味ある方は下記のリンクからどうぞ!
Code Mafiaさんのコース

早くMarkdown記法にもなれていきたいです☺️


アロー関数を使わない記法で書いた場合

const hello = function(name){
  console.log('hello' + name);
}

hello('code mafia');
hello('code mafia2');
hello();
  • const hello = function (name = 'Tomo') とデフォルト値を設定してあげることも可能

アロー関数を使った場合

const hello = name => console.log(name);

hello('code mafia');
hello('code mafia2');
hello();

戻り値が設定してある場合

const hello = (name, age) => {
  return 40;
}

アロー関数を使うと

const hello = (name, age) => 40;

と記述することができる。

const arry = [1,2,3,4,5,6];

arry.forEach(value => console.log(value));

と配列の値をそれぞれ出すことができる。少し見慣れなかもしれないけど
書いていくうちに慣れていきたいと思う

0
0
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
0