Skip to content

Instantly share code, notes, and snippets.

View KScaesar's full-sized avatar

Caesar M. Tsai KScaesar

View GitHub Profile
@KScaesar
KScaesar / Foo.js
Last active August 31, 2018 13:38
test prototype
function Foo(){
this.testArr=[2,4];
};
Foo.prototype={
str:'test',
num:1,
arr:[1,2],
obj:{a:2}
};
@KScaesar
KScaesar / Object_create.js
Created August 27, 2018 15:52
javascript Object.create
Object.create = function (obj) {
var F = function () {}; //1.生成新的建構函數
F.prototype = obj; //2.連接新建構函數的prototype到obj
return new F(); //3.返回用F製造出來的新物件,
// F為沒有內容的空函數,返回物件的__proto__連接obj
// 返回物件被設為空函數F的this綁定
};