Null and Undefined represent the lack of value.
When we create a variable but do not assign(分配) any value to it. Its value and data type becomes undefined.
var noValue;//var noValue=""=尚未放值
console.log(noValue); // undefined
console.log(typeof noValue); // undefined
Undefined can also appear on other cases, for example when we try to access an index that does not exist in a string:
var name = "Peter";
console.log(name[0]); // Console will show "P"
console.log(name[4]); // Console will show "r"
console.log(name[10]); // Console will show undefined
var temperature = 35;
console.log(temperature);
temperature = null;
console.log(temperature); // The console will show null
console.log(typeof temperature); // The console will show object - which could be misleading(誤導)