ReferenceError: “alert” is not defined

用Node.js单独运行js文件时,其中定义的alert不可用web

alert is not part of JavaScript, it's part of the window object provided by web browsers. ide

var name = "The Window";

function ttt() {

return(this.name);
}
alert(ttt.call(window);
//alert(window);

var object = {

name : "My Object",
getNameFunc : function(){

return function(){

return this.name;
};
}};

console.log(object.getNameFunc()()); // console The Windowvar name = "The Window";

var object = {
name : "My Object",
getNameFunc : function(){
var that = this;
return function(){
return that.name;
};
}};

console.log(object.getNameFunc()()); //console My Object
 
     
 
     
若是是在Node.js中运行的话,window会提示“undedined”。
相关文章
相关标签/搜索