Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/471.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在类中访问公共变量javascript_Javascript - Fatal编程技术网

在类中访问公共变量javascript

在类中访问公共变量javascript,javascript,Javascript,我有一个Javascript类,它有三个文本变量: myClasss = function(){ this.color = "yellow"; this.type = "car"; this.other = this.type + ", " + this.color; } 我的班级有一个错误。 如何填充此.Other?除了定义其工作函数后缺少的分号之外 myClasss = function() { this.color = "yellow"; this

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

myClasss = function(){
    this.color = "yellow";
    this.type = "car";
    this.other = this.type + ", " + this.color;
}
我的班级有一个错误。
如何填充此.Other?

除了定义其工作函数后缺少的分号之外

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