Skip to content

Error Handling & Strict Mode

Error Handling
Typeof
var a = 3;
console.log(typeof a);

var b = "Hello";
console.log(typeof b);

var c = {};
console.log(typeof c);

var d = [];
console.log(typeof d); // weird!
console.log(Object.prototype.toString.call(d)); // better!

function Person(name) {
this.name = name;
}

var e = new Person('Jane');
console.log(typeof e);
console.log(e instanceof Person); // e có phải là được tạo ra từ Person()

console.log(typeof undefined); // makes sense
console.log(typeof null); // a bug since, like, forever...

var z = function() { };
console.log(typeof z);
StrictMode
luôn phải khai báo biến trước khi sử dụng
có thể 'use strict' ở đầu file hoặc function
Đọc thêm tại đây

Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.