'Funct Object'in js


もっと読む
Here is a paper that introduce the'Function Object'in javascript.
http://www.permadi.com/tutorial/jsFunc/index.html
私の理解点:関数はエンティティと結合しません。関数はどこでも使えるので、数値として見られます。javaのような種類ではない方法は、類名と結びつけられているに違いない。(この思考転換は確かに難しいです)
コードの例で説明する:

1.
Engine.prototype.start = function(){
	var eventEngine = this;
	    window.setInterval(function(){eventEngine.GetEventsInfo();},5000);
	
}
を選択します

2.
Engine.prototype.start = function(){
	var eventEngine = this;
	    window.setInterval(eventEngine.GetEventsInfo,5000);	
}
違いが大きくなりました。2のwindow.setIntervalが最初のパラメータを伝えたのは関数だけです。GetEvents Info()関数体に入ると、thisはevent Ent Egineを指しません。第一の例では、このようになります。
参照
eventEngine.GetEvents Info()
操作はパッケージ化され、GetEvents Info()関数の体内に入ります。

3.
Engine.prototype.start = function(){
	var eventEngine = this;
	    window.setInterval('eventEngine.GetEventsInfo()',5000);	
}
これは三つ目の実現可能なやり方です。jsはこのような文字列'eventEntine.GetEvents Info''を探しに行きます。マッチング文字列の関数が見つかると、対応する方法を呼び出します。
この特性は思い出せません。何と言っていますか?
window.setInterval(fucntion , time);
if(function=='Function()'){
    //...
}else{
    //find the String in Function stack;
    var result = search('function');
    if(result){
      //...      
    }
    else{
     //error!
    }
   
}
)