Javascript语法:意外标识符错误

时间:2013-07-30 20:39:37

标签: javascript

我这样做,我在isReady行上收到错误。

我做错了什么?

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

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

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

2 个答案:

答案 0 :(得分:2)

您需要逗号,因为您正在定义一个对象:

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

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

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


};

答案 1 :(得分:2)

每个函数定义后都需要逗号,例如:

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

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

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