😽
Javascriptのセミコロン
セミコロンなしだとエラー
$ sample.js
const a = 'foo' // Not semicolon
(async () => {
console.log(a)
})();
$ node sample.js
(async () => {
^
TypeError: "foo" is not a function
at Object.<anonymous> (/home/tsaeki/Develop/test_azure_pipeline/test2.js:3:1)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47
セミコロンありはOK
$ sample_fix.js
const a = 'foo'; // Add semicolon
(async () => {
console.log(a);
})();
$ node sample_fix.js
foo
Discussion