LoginSignup
3
0

More than 3 years have passed since last update.

【JavaScript 】アロー関数の書き方

Last updated at Posted at 2020-01-14

アロー関数の書き方を学んだのでやってみました!

基本の関数

function func(text) {
    console.log(text);
}

やってみた
スクリーンショット 2019-11-29 9.59.45.png

アロー関数で書いてみた

const test = () => {
    console.log('アロー関数書き方');
}
test();
// console.logの結果が返ってくる

やってみた
スクリーンショット 2019-11-29 9.43.28.png

↑この書き方は省略できて…

省略形

const test2 = () => console.log('test2');
test2();

やってみた
スクリーンショット 2019-12-03 9.40.25.png

引数がある場合

const test3 = (text) => console.log(text); 
test3('test3引数');
//test3引数 が返ってくる

やってみた
スクリーンショット 2019-12-03 9.50.44.png


これと同じ動きをする省略しない書き方

function test4(text) {
    console.log(text);
}
test4(1111) //1111

やってみた
スクリーンショット 2019-12-08 3.56.17.png

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