在课堂上访问公共变量javascript

时间:2012-11-22 05:35:01

标签: javascript

我有一个Javascript类,它有三个文本变量:

myClasss = function(){
    this.color = "yellow";
    this.type = "car";
    this.other = this.type + ", " + this.color;
}

我的课有错误。 如何填写this.Other

1 个答案:

答案 0 :(得分:0)

除了功能定义后缺少的分号,它还可以。

myClasss = function() {
    this.color = "yellow";
    this.type = "car";
    this.other = this.type + ", " + this.color;
};
alert(new myClasss().other == "car, yellow");

You can see it in jsFiddle