苹果熊

#1 Created at ... [Delete] [Delete and Lock User]

实际上,JavaScript默认有一个全局对象window。 这个说法有点不严谨吧,应该要加个具体环境。Node环境里就没有window对象了

rccoder

#2 Created at ... [Delete] [Delete and Lock User]

这点的确不是很严谨,应该修改一下

做为一套优秀的系统的教程,循序渐进是一定要的,这才到哪,你们把node搬出来,廖老师的教程我看得手不释卷。

iridiumcao

#4 Created at ... [Delete] [Delete and Lock User]

看来读评论也是必须的。 这里如果在文章中提一下,倒也无不可的。

window.onload=function () {

var echo = document.write;
document.write = function ()
{
    alert('此方法,已经被重写')
}

function showezi (){
 var birth = 1998;
 var y = new Date().getFullYear();
    return y - this.birth;
}

echo ('123')

} 报错内容 :javascript.js:16 Uncaught TypeError: Illegal invocation,如果我把上面的document.write换成alert;就可以赋值alert方法,但是document.write就不行呢。各位老师帮我看一下吧。

window.onload=function () {

var echo = document.write; document.write = function () { alert('此方法,已经被重写') }

function showezi (){ var birth = 1998; var y = new Date().getFullYear(); return y - this.birth; }

echo ('123') } 我的报错信息是这样的: window.onload=function () { var echo = document.write; document.write = function () { alert('此方法,已经被重写') }
VM23013:7 Uncaught SyntaxError: Unexpected end of input function showezi (){ var birth = 1998;
VM23083:2 Uncaught SyntaxError: Unexpected end of input var y = new Date().getFullYear(); undefined return y - this.birth; VM23159:1 Uncaught SyntaxError: Illegal return statement } VM23163:1 Uncaught SyntaxError: Unexpected token } echo ('123') VM23187:1 Uncaught ReferenceError: echo is not defined at <anonymous>:1:1 (anonymous) @ VM23187:1

栖安i

#7 Created at ... [Delete] [Delete and Lock User]

js运行时内置了一个Global对象 这个Global对象跟运行环境有关。在浏览器运行环境中。Global就是window对象。 在nodejs中。Global对象是global对象。


  • 1

Reply