JavaScript アロー関数で引数がないサンプル

環境
Windows 10 home 64bit
Google Chrome 107.0.5304.122

構文
引数 = () => {処理コード}
引数がない時も引数の箇所にかっこ()が必要です。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
const city = () => {
return "東京です";
};
console.log(city());
const city = () => { return "東京です"; }; console.log(city());
 const city = () => {
    return "東京です";
  };

console.log(city());

実行結果
> “東京です"

JavaScript

Posted by arkgame