[コンストラクタ]
[メンバ変数]
[メンバ関数]
[使用例]
- var car = function(){};
[メンバ変数]
メンバ変数にはthisを付ける。
- var car = function( _maker, _color ){
- this.maker = _maker;
- this.color = _color;
- };
[メンバ関数]
- var car = function( _maker, _color ){
- this.maker = _maker;
- this.color = _color;
- };
- car.prototype = {
- getColor : function(){
- alert( "この車の色は" + this.color + "です。" );
- }
- }
[使用例]
- var car = function( _maker, _color ){
- this.maker = _maker;
- this.color = _color;
- };
- car.prototype = {
- getColor : function(){
- alert( "この車の色は" + this.color + "です。" );
- }
- }
- var myCar = new car( "toyota", "white" );
- myCar.getColor();
0 件のコメント:
コメントを投稿