2013-07-30 52 views
-1

我正在執行此操作,並在isReady行上發生錯誤。JavaScript語法:意外標識符錯誤

我在做什麼錯?

var CTRecorder = { 
    returnCheckFile:function(bool){ 
     alert(bool); 
    } 

    isReady:function(){ 
     alert("the player is ready"); 
    } 

    timeArray:function(x){ 
     $("#timeArrayDIV").html(x); 
    } 
}; 
+3

你缺少關鍵定義之間的逗號。 – Mathletics

+3

這個語法問題太過基礎,不具有價值。 – Mathletics

+0

嗯,我很抱歉有太基本的問題 – Houseman

回答

2

你需要每個函數定義後的逗號,如:

var CTRecorder = 
{ 
    returnCheckFile:function(bool){ 
     alert(bool); 
    }, 

    isReady:function(){ 
     alert("the player is ready"); 
    }, 

    timeArray:function(x){ 
     $("#timeArrayDIV").html(x); 
    } 
}; 
2

你需要逗號,因爲你要定義一個對象:

var CTRecorder = 
{ 
    returnCheckFile:function(bool){ 
     alert(bool); 
    }, 

    isReady:function(){ 
     alert("the player is ready"); 
    }, 

    timeArray:function(x){ 
     $("#timeArrayDIV").html(x); 
    } 


};