Native prototypes

Object.prototype

// obj = {} 等於 obj = new Object(),Object 是內建建構函式
let obj = {};
alert( obj ); // "[object Object]" ?

// check
let obj = {};
alert(obj.__proto__ === Object.prototype); // true
// obj.toString === obj.__proto__.toString == Object.prototype.toString

alert(Object.prototype.__proto__); // null

Other built-in prototypes

Primitives

string、number、boolean 本身不是物件,但在使用他們的屬性時,內建的建構函式 String、Number、Boolean 會暫時創造包裝物件提供方法。null、undefined 沒有包裝物件,也就是沒有屬性或方法。

Changing native prototypes

Borrowing from prototypes

Last updated

Was this helpful?