Hoisting
Introduction
Normal Function / var
var x = 1; // 初始化 x
console.log(x + " " + y); // '1 undefined'
var y = 2;
//上下的程式結果都一樣
var x = 1; // 初始化 x
var y; // 宣告 y
console.log(x + " " + y); // '1 undefined'
y = 2; // 初始化 y
test();
function test() {
console.log("test");
}
// Output: test
Arrow Function / let and const
Last updated