JavaScriptの関数の書き方|基本中の基本

宣言関数(名前付き関数)

function    myFunc(familyName)
{
    console.log(familyName);
    return  familyName    +   "太郎";
}

console.log(myFunc("山田"));

無名関数

let name  =   function(familyName)
{
    console.log(familyName);
    return  familyName  +   "太郎";
}

console.log(name("山田"));

即時関数

(function (familyName, firstName)
{
    console.log(familyName  +   firstName);
}("山田", '太郎'));

アロー関数

let name    =   (familyName)    =>
{
    console.log(familyName);
    return  familyName  +   "太郎";
}

console.log(name("山田"));

コメント