ありしんのブログ
Just another WordPress site
-
10月 18th, 2012JavaScript
JavaScriptの機能
・オブジェクト(関数)
・プロトタイプ
やり方①
function C(){ –>Constracter definition
this.x = 0;
this.y = 0;
}
C.prototype.f = function(){ –>Static member definition
return this.x * this.y;
};
ver c = newC(); –>Intancing definition
やり方②
var C = function(){
}
やり方③
var C = {
x = 0,
y = 0,
f = function(){}
};
派生(継承)
var C2 = new ();
C2.prototype.hoge = function();
var C3 = new C2();
-