Help us understand the problem. What is going on with this article?

JavaScript関数・引数・戻り値

関数

main.js
const kansu = function(){
    console.log("関数がうごいた!");
}
kansu();
関数がうごいた!

アロー関数

main.js
const arrawKansu = () =>{
    console.log('アロー関数が動いた!');
}

arrawKansu();
アロー関数が動いた!

引数

main.js
'use strict';
const eat = (name) =>{
    console.log(`飯の名前${name}`);
}

eat('カレー');
eat('チャーハン');
eat('白飯');
飯の名前カレー
飯の名前チャーハン
飯の名前白飯

複数の引数

main.js
const person = (firstName,lastName) =>{
    console.log(`「姓」:${firstName}「名」:${lastName}`);
}
person('鈴木','一郎');
person('田中','太郎');
「姓」:鈴木「名」:一郎
「姓」:田中「名」:太郎

戻り値

main.js
const person = (firstName,lastName) =>{
    console.log(firstName);
    console.log(lastName);
    return firstName + lastName;
}
const personName = person('鈴木','一郎');
console.log(personName);
鈴木
一郎
鈴木一郎
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away