SlideShare une entreprise Scribd logo
1  sur  9
JavaScript による
楽しいオブジェクト指向
プログラミング
片山 真也
どう書くの?
var Drug = function(name) {
this.name = name;

};
var hoge = new Drug(“hoge”);

var foo = new Drug(“foo”);
Drug.prototype.take = function() {
// 処理
}
hoge.take();
take

Drug

prototype

constructor

hoge

foo
name

name
“hoge”

“foo”
継承
var Super = function() {};
var Child = function() {};

Child.prototype = new Super();
Super

prototype

constructor

Child
constructor

prototype

プロトタイプ
チェーン
スーパーメソッド
Super.prototype.hoge = function(arg) {};

this
this.constructor
.prototype
.hoge .call(this, arg);
プライベート変数・関数
var Drug = function() { /* 初期化*/ };
(function() {
var private = function() {};
Drug.prototype.public = function() {};

})();

Contenu connexe

Plus de kata shin

6月26日 LT会
6月26日 LT会6月26日 LT会
6月26日 LT会kata shin
 
JSSST 2014 発表資料
JSSST 2014 発表資料JSSST 2014 発表資料
JSSST 2014 発表資料kata shin
 
Generational Layered Canvas Mechanism for Collaborative Web Applications
Generational Layered Canvas Mechanism for Collaborative Web ApplicationsGenerational Layered Canvas Mechanism for Collaborative Web Applications
Generational Layered Canvas Mechanism for Collaborative Web Applicationskata shin
 
新谷研プログラミングコンテスト2014 発表資料
新谷研プログラミングコンテスト2014 発表資料新谷研プログラミングコンテスト2014 発表資料
新谷研プログラミングコンテスト2014 発表資料kata shin
 
JSAI2014 発表資料
JSAI2014 発表資料JSAI2014 発表資料
JSAI2014 発表資料kata shin
 
新谷・大囿研究室 2014年度引き継ぎ講習会 フレームワーク
新谷・大囿研究室 2014年度引き継ぎ講習会 フレームワーク新谷・大囿研究室 2014年度引き継ぎ講習会 フレームワーク
新谷・大囿研究室 2014年度引き継ぎ講習会 フレームワークkata shin
 

Plus de kata shin (6)

6月26日 LT会
6月26日 LT会6月26日 LT会
6月26日 LT会
 
JSSST 2014 発表資料
JSSST 2014 発表資料JSSST 2014 発表資料
JSSST 2014 発表資料
 
Generational Layered Canvas Mechanism for Collaborative Web Applications
Generational Layered Canvas Mechanism for Collaborative Web ApplicationsGenerational Layered Canvas Mechanism for Collaborative Web Applications
Generational Layered Canvas Mechanism for Collaborative Web Applications
 
新谷研プログラミングコンテスト2014 発表資料
新谷研プログラミングコンテスト2014 発表資料新谷研プログラミングコンテスト2014 発表資料
新谷研プログラミングコンテスト2014 発表資料
 
JSAI2014 発表資料
JSAI2014 発表資料JSAI2014 発表資料
JSAI2014 発表資料
 
新谷・大囿研究室 2014年度引き継ぎ講習会 フレームワーク
新谷・大囿研究室 2014年度引き継ぎ講習会 フレームワーク新谷・大囿研究室 2014年度引き継ぎ講習会 フレームワーク
新谷・大囿研究室 2014年度引き継ぎ講習会 フレームワーク
 

JavaScript による楽しいオブジェクト指向プログラミング