错误。format不是javascript函数

错误。format不是javascript函数,javascript,Javascript,嘿,我正在用javascript创建这个时钟,因为我已经编写了我的代码,但是有一个错误是{00}+{00}+{00}。format不是一个函数 class Counter { constructer(Name) { this.count = 0; this.name = Name; } get Value(){ return this.count; } get Name(){ return this.name; } set Name(valu

嘿,我正在用javascript创建这个时钟,因为我已经编写了我的代码,但是有一个错误是{00}+{00}+{00}。format不是一个函数

class Counter
{
 constructer(Name)
{
    this.count = 0;
    this.name = Name;   
}

get Value(){
    return this.count;
}

get Name(){
    return this.name;   
}


set Name(value){
    this.name = value;  
}
Increment()
{
    this.count++;   
}
Reset()
{
    this.count = 0;
}


}
这是我的时钟类,其中有一个时间方法,有格式的东西,如果有人能帮助我,基本上我打印小时分钟和秒的00格式

class clock
{

constructer()
{
    this._hour = new Counter("hour");
    this._minutes = new Counter("Minutes");
    thi._seconds = new Counter("Seconds");
}

["Time"](){

    var time = '{"00"} + {"00"} + {"00"}'.format(this._hour, this._minutes, this._seconds);
}   

["Reset"]()
{
    this._hour.Reset();
    this._minutes.Reset();
    this._seconds.Reset();
}   

["Tick"]()
{
    this._seconds.Increment();
    if(_seconds.Value == 60)
    {
        _minutes.Increment();
        _seconds.Reset();
    }
    if(_minutes.Value == 60)
    {
        _hour.Increment();
        _minutes.Reset();
        _seconds.Reset();
    }   
    if(_hour == 24)
    {
        Reset();
    }
}

}

您只需将数字串接为字符串即可。以下代码将打印字符串
9:11:56

hours = 9
minutes = 11
seconds = 56

console.log(hours + ":" + minutes + ":" + seconds)

下面是对REPL.it上相同代码的一个注释。

Well。你凭什么认为他们会这么做?另外,
[“Tick”](
)等可以写成
Tick()
。javascript字符串没有格式属性-您考虑的是一些虚构的语言,而不是
[“Time”]({
..
}
您也可以简单地使用
“Time”{
..
}
Time(){
..
}
constructor
不是构造函数。
this.\u seconds.Increment()。。。如果(_seconds.Value==60)
没有
这个,你就
。。。看起来你已经在键盘上随机地砸了你的手,并且期望javascript能够