简体   繁体   中英

What is the correlation between ECMAScript 5 and JavaScript 1.8.5 in terms of language features?

I've been reading up on Mozilla's continuing development of JavaScript, up through version 1.8.5: https://developer.mozilla.org/en/JavaScript .

My question is: What is the correlation between JavaScript 1.8.5+ and ECMAScript 5+ in terms of language features? Any chance Mozilla's new JavaScript features (like generators, array comprehensions, etc.) will become part of ECMAScript?

I just want to get a handle on whether it's worth learning JavaScript 1.8.5 features (and working to shim them into non-supporting browsers) or whether I should forget JS 1.8.5 and focus on learning/shimming the new ECMAScript 5 features.

FYI: Mozilla talks about how they're planning to bring JavaScript into compliance with ECMAScript 5 here: https://developer.mozilla.org/En/JavaScript/ECMAScript_5_support_in_Mozilla

JavaScript 1.8.5 is Mozilla's implementation of ECMAScript with added features. It's a superset of the ECMAScript specification (and of current implementations like IE, Chrome and Opera). Mozilla pushes for the features it adds to its own browser, they may or may not make it into ECMA. Note that Mozilla is a member of the W3C and has some say, but my guess is that most features won't make it.

Bottom Line Don't use it unless you're coding something specific to firefox, FF extensions, XUL apps, Rhino (Added Rhino thanks to @Raynos)

Defiantly focus on ES5. The issue with 1.7 & 1.8 features is that they change the syntax of the language so you can't shim them into other code.

You can emulate all the properties of the Object with ES5 but you can't emulate the let keyword. In other browsers the various expression are just not valid javascript.

You must distinquish between making addition to native code which is what most of ES5 is doing and changing the syntax of javascript which is what 1.7 & 1.8 are doing.

There is a use for 1.7 & 1.8 which is to develop for the RHINO platform. But for browser javascript stick to the spec.

Admittedly the multiple value returns is a pretty neat feature. Having an array assignment like that would be nice

function() f {
     return [1,2,3];
}

[a,b,c] = f()

But the other features are quite major changes to the syntax and you just can't push them through ecmascript they just won't deal with it. Small changes like above you might be able to get into ES6 but your going to have to wait at least a year.

So realistically don't expect the learning to pay off for a year or two if at all. Most likely it won't pay off. Do look at libraries such as underscore.js which can define common functional utility methods for you.

I think ECMAScript is the "standard", like a blueprint, and javascript is the actual language it is based off of. Kind of like how w3c has their standards and then people make (or don't) make rendering engines based off it.

So basically to answer your question, look at ECMAScript to see what the consensus is, how javascript is "supposed" to work, but you should focus on javascript, because that's what you will actually be coding with.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM