Javascript普通に書いてたら、DOMいじることが多く、ガッツリとオブジェクトを書くことが少ない。ちょっと再帰処理をやろうとおもったら、嵌まり込みそうになった。 最近のJavascriptにおける継承と制御についてまとめておいた。 昔からあるJavascriptのnew var Cat = function(name){ this.name = name; this.say = function(){ console.log("My name is "+this.name+" Nya Nyan") } } a_cat = new Cat("みー") a_cat.say() // => "My name is みー Nya Nyan" これは、昔からあるjavascript の書き方で、今でも動くし、これで十分なことが多い。 ここでは、 コンストラクタ関数の定義、new 演算子、プロパ