LoginSignup
0
0

More than 1 year has passed since last update.

無名関数

Last updated at Posted at 2021-06-04

無名関数


無名関数は関数名なしで関数を定義することができます。より簡潔なコードが記述できると言うメリットがあります。

//関数宣言
function hello(){
 console.log('hello')
}

//関数式(無名関数)
const hello = function(){
 console.log('hello')
}

以下のコードを記述して、12と出力されていれば成功です。

const calc = function(num1,num2){
 return num1*num2
}

const num1 = 3
const num2 = 4
console.log(calc(num1,num2))
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