且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么在使用它之前在Javascript中声明变量不是必须的?

更新时间:2023-10-28 08:59:28

Javascript用于浏览器中非常简单的脚本。需要变量声明似乎没必要。

Javascript was intended for very simple scripts in the browser. Requiring variable declarations seemed unnecessary.

当然,这是语言中的一个错误。而javascript的制作者知道。他们想改变它。但他们不能。为什么?

Of course, it's an error in the language. And the makers of javascript know that. They wanted to change it. But they couldn't. Why?

因为微软已经反向设计了JavaScript并创建了他们的重复JScript,带有错误和所有。微软否决了任何更改,甚至是错误修正,因为他们坚持不破坏任何人的脚本。所以甚至如果他们改变了JavaScript,IE中的JScript将保持不变。

Because Microsoft had already reverse engineered JavaScript and created their duplicate JScript, with bugs and all. Microsoft vetoed any changes, even bugfixes, since they were adamant about not breaking anyones scripts. So even if they changed JavaScript, JScript in IE would stay the same.

这不是一个好理由。但它就是我们拥有的那个。

It's not a good reason. But it's the one we have.

来源:我从Douglas Crockford获得了我的javascript历史课:JavaScript编程语言, http://video.yahoo.com/watch/111593/1710507 故事的这一部分是在9到11分钟之间进入视频。

Source: I got my javascript history class from Douglas Crockford: "The JavaScript Programming Language", http://video.yahoo.com/watch/111593/1710507 This part of the story is between 9 and 11 minutes into the video.