今日やったこと/Reactの復習とか/行儀の良い書き方とか
今日やったこと
PythonとかScikit-learnにもすこし飽きて、動きがあるものを作りたいなと思ったので javascriptを触ることに
React流行っているし4月に本も出るようなので今更キャッチアップした
React Tutorial チュートリをひと通りおわらせた。 やっぱコードを写経すると理解度が上がりますね。 感想としては、JSXが混ざるのが若干気持ち悪いものの、データの流れがすんなり整理されるのでなかなか使いやすそうなフレームワーク(ライブラリ)
Virtual DOMの利点とかその辺も深くわかるようになりたいっすね。
最近の行儀の良い書き方
(function(global){ "use strict;" // Class function Hoge() { }; //Header Hoge["prototype"]["constructor"] = Hoge; Hoge["prototype"]["methodHoge"] = methodHoge; Hoge["prototype"]["methodPlus"] = methodPlus; // implementation function methodHoge(arg) { console.log("fugafuga"); }; function methodPlus(a, b) { var c = a + b; console.log(a + " + " + b + " = " + c); }; // Exports if ("process" in global) { module["exports"] = Hoge; }; global["Hoge"] = Hoge; })((this || 0).self || global); //ブラウザだったらthis == windowになる (function(globa){ hogeInstance = new global.Hoge(); console.log(hogeInstance); //call function hogeInstance.methodHoge(); hogeInstance.methodPlus(1, 2); })((this || 0).self || global);