警告 - 危险地使用全局 this 对象?
WARNING - dangerous use of the global this object?
Google 闭包编译器抱怨这段代码:
function Message() {
this.message = "";
this.nickname = "";
this.time = 0;
this.my = false;
};
这里有什么危险?它应该如何创建 "objects"?现在我做
var m = new Message();
获取 "type" 消息的初始化对象。
尝试注释代码以告诉编译器这是一个构造函数:
/**
* A message
* @constructor
*/
function Message() {
this.message = "";
this.nickname = "";
this.time = 0;
this.my = false;
};
见https://developers.google.com/closure/compiler/docs/js-for-compiler#overview
Google 闭包编译器抱怨这段代码:
function Message() {
this.message = "";
this.nickname = "";
this.time = 0;
this.my = false;
};
这里有什么危险?它应该如何创建 "objects"?现在我做
var m = new Message();
获取 "type" 消息的初始化对象。
尝试注释代码以告诉编译器这是一个构造函数:
/**
* A message
* @constructor
*/
function Message() {
this.message = "";
this.nickname = "";
this.time = 0;
this.my = false;
};
见https://developers.google.com/closure/compiler/docs/js-for-compiler#overview