Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
177 views
in Technique[技术] by (71.8m points)

python - What is cross browser support for JavaScript 1.7's new features? Specifically array comprehensions and the "let" statement

https://developer.mozilla.org/en/New_in_JavaScript_1.7

A lot of these new features are borrowed from Python, and would allow the creation of less verbose apps, which is always a good thing. How many times have you typed

for (i = 0; i < arr.length; i++) {
    /* ... */
}

for really simple operations? Wouldn't this be easier:

[/* ... */ for each (i in arr)]

I think brevity is a great thing. Basically, it all comes down to IE in the end, though.

Does IE support these new features? What about other browsers?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

While this question is a bit old, and is marked "answered" - I found it on Google and the answers given are possibly inaccurate, or if not, definitely incomplete.

It's very important to note that Javascript is NOT A STANDARD. Ken correctly mentioned that ECMAScript is the cross-browser standard that all browsers aim to comply with, but what he didn't clarify is that Javascript is NOT ECMAScript.

To say Javascript "implements" ECMAScript means that Javascript includes ECMAScript, plus it's own proprietary extra non-cross-browser features. The for each example given by nicholas is an example of a proprietary feature added by Mozilla that is not in any standard, and therefore unlikely to be adopted by any other browsers.

Javascript 1.7 and 1.8 features are useful for extension development in XUL, but should never be used for cross-browser development - that's what standards are for.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...