若手IT勉強会 第5回勉強会 サイ本読書会 第7章・第10章
第5回勉強会 - 若手IT勉強会 - アットウィキ
サイ本 第7章メモ - すがブロ
7.5 配列
[1,2,].length;//2 [,].length;//1 [,][0] === undefined;//true [,,].length;//2
- 最後のカンマの後に何も書かれていないと無視される。
- カンマ前に何も書かれていないとundefinedが書かれているのと等価になる
若手IT勉強会 第5回勉強会 サイ本読書会 第8章
第5回勉強会 - 若手IT勉強会 - アットウィキ
↓を使ってコードの実行デモをやった。
Learning Advanced JavaScript
8.2.2 Argumentsオブジェクト
8.4 メソッドとしての関数
- thisキーワード : その関数がどのオブジェクトのメソッドとして呼ばれたか
- 関数として呼ばれた場合にはthisはグローバル
- キーワードなので値を代入出来ない
8.6.1 (関数の)lengthプロパティ
- lengthプロパティ(arguments.callee.length) : 関数の仮引数の個数
8.8.2 Callオブジェクト
- argumentsとローカル変数はCallオブジェクトのプロパティ
8.8.4.1 クロージャの例
クロージャによるデータ隠蔽
ブレークポイントシステム
alert(factorial(3)); function factorial(n){ var inspector = function($){return eval($);}; inspect(inspector,'Entering factorial()'); var result = 1; while(n > 1){ result = result * n; n--; inspect(inspector,'factorial() loop'); } inspect(inspector,'Exiting factorial()'); return result; } function inspect(inspector,title){ var expression,result; while(true){ var message = (title || '') + ',' + 'result:' + (result || ''); expression = prompt(message,expression); if(!expression)return; result = inspector(expression); } }
若手IT勉強会 - 第5回勉強会 サイ本読書会第9章
第5回勉強会 - 若手IT勉強会 - アットウィキ
↓を使ってコードの実行デモをやった。
Learning Advanced JavaScript
随時更新
9.2.1継承プロパティへのアクセス
読み書きで非対称になっている
読み込み
- オブジェクト自身のプロパティの存在チェック
- プロトタイプのプロパティの存在チェック
書き込み
- 常にオブジェクト自身のプロパティに書き込み
function Hoge(x){ this.x = x; } Hoge.prototype = {getX : function(){return this.x;} ,y:4 }; var hoge = new Hoge(3); hoge.y=3; log(hoge.y); log(Hoge.prototype.y);
9.5 スーパークラスとサブクラス
constructorプロパティの書き換えが必要な条件は?
9.7.1 instanceof演算子
プロトタイプチェーン上のすべてのコンストラクタでtrue
function Hoge(){ } Hoge.prototype = new Date(); (new Hoge()) instanceof Hoge;//true (new Hoge()) instanceof Date;//true (new Hoge()) instanceof Object;//true
7.4.7 isPrototypeOfメソッド
Hoge.prototype.isPrototypeOf(new Hoge());//true Date.prototype.isPrototypeOf(new Hoge());//true Object.prototype.isPrototypeOf(new Hoge());//true