I would like to see list of changes that were made in every version of JavaScript. I would also be interested in what is planned to be added in JavaScript and when a new realease is planned.
Do you know any site where this info can be found?
Thank you
The standard it is based around: Ecmascript specs: http://www.ecma-international.org/publications/standards/Ecma-262.htm
Firefox specifics:
MDC javascript docs including differences in javascript versions: https://developer.mozilla.org/en/javascript
IE specifics: MSDN library, scripting area: http://msdn.microsoft.com/en-us/library/ff729665(v=VS.94).aspx
JavaScript is a dialect of ECMAScript, have a look at the Wikipedia page of ECMAScript for a version history. You can find the full documentation on the official ECMAScript page.
Related
When you crate a new Google Apps Script, it seems to support the v8 runtime by default. The documentation states:
Apps Script supports two JavaScript runtimes: the modern V8 runtime and an older one powered by Mozilla's Rhino JavaScript interpreter.
The V8 runtime supports modern ECMAScript syntax and features.
The V8 runtime documentation states:
You can use modern ECMAScript syntax in scripts that are powered by the V8 runtime. This syntax includes let, const, and many other popular features.
In both cases, they are very vague as to which ECMAScript version is supported, simply stating "modern ECMAScript syntax". This is problematic because there are 7 versions that were released between 2015 and 2021. Thus "modern" could refer to any one of these versions.
For example, I could easily assume that "modern" refers to the latest, 12th edition (2022) of ECMAScript, and end up writing code like this:
let a = 1_000;
However, attempting to use that syntax leads to the error:
Syntax error: ParseError: Unexpected token ILLEGAL line: ...
Rather than manually go through each of the remaining 6 versions until I find the latest one supported, it would be great to find documentation that explicitly states which ECMAScript version is supported.
Note: The previous related question (Which Edition of ECMA-262 Does Google Apps Script Support?) is not helpful since those answers also refer to "modern ECMAScript" rather than a definitive, specific version.
Which version of ECMAScript is supported by the V8 runtime?
There is some nuance here:
Which version of V8 does Google Apps Script use?
A reasonably recent version, and it gets updated every so often. I believe the idea is to track or slightly lag behind stable Chrome releases, but (as with any large project updating its dependencies) there may occasionally be hiccups/delays. Right now it should be somewhere in the 9.x version range. (For future readers: I expect this statement to be outdated before 2022 is over!)
Which version of ECMAScript does the Google Apps Script V8 Runtime Support?
I suppose if there was a simple answer to this, you'd find that in the documentation. As #Kaiido said in comments, JavaScript engines implement new JavaScript features one by one (rather than EcmaScript versions). So, for browsers just like for environments like GAS, it usually makes more sense to ask "is feature X supported?", because it may well be that some, say, ES2020 features are still missing but some ES2021 features are already available.
Why does let a = 1_000; produce a Syntax Error?
Well, the V8 version that GAS uses is sufficiently new (by at least two years) to support it; but the overall GAS experience depends on more than V8: the editor is parsing the entered source in order to provide help or highlighting or error checking or whatnot. It looks like the GAS team is aware that certain features aren't supported yet by the components responsible for that, and is actively working to remedy that. (I have no idea what the timeline is.)
Why does let a = 1_000; produce a Syntax Error?
Just to expand on #jmrk's answer about new features not supported by the parser.
function test2564(){
//let a = 1_000; throws syntax error by the parser
console.info(eval(`1_000`));// correctly logs 1000
}
The underlying V8 engine is good and supports the latest features, but the parser won't allow you to save or execute the project with those features, as it considers them as syntax errors.
Hey I have an interesting question, I work with a platform that uses server-side javascript, but unfortunately this platform only supports ECMAscript 3.0. What's the easiest way for me to tell what arrays/methods are available for me to use within thi version?
I know some of the obvious things (i.e. arrow functions and most array methods), but i've definitely spent hours over code, wondering why it wasn't working in this platform, to figure out it's because i'm using an unsupported method.
MDN links are broken, ECMA official website seem to have the archives. Please check this pdf.
https://www.ecma-international.org/wp-content/uploads/ECMA-262_3rd_edition_december_1999.pdf
Online archives for all historical versions are available at this link
https://www.ecma-international.org/publications-and-standards/standards/ecma-262/
You can write your code with the most recent ES features and then use babel to transpile it to ES 3 before pushing to production. That's much easier than figuring out what you can use on ES 3.
I think there's a VS Code extension that simplifies the use of babel (similarly to what Live SASS Compiler does to convert SASS to CSS)
I was looking at Mozilla Developer Documentation on Javascript. Is it Mozilla's interpretation of the ECMAScript standard or is it documenting how they have implemented Javascript in Firefox?
Basically, I want to know whether their documentation is valid across all browsers or just Firefox.
It's both, basically. From JavaScript/Reference/About:
The JavaScript Reference serves as a repository of facts about the
JavaScript language. The entire language is described here in detail. […]
Recent versions of Mozilla-based browsers support newer versions of
JavaScript. […]
Browsers that do not support at least JavaScript 1.5 are very rare
today, since JavaScript 1.5 was introduced back in 1999. If you're
interested in historic information, please refer to the Wikipedia
article on ECMAScript.
JavaScript documentation of core language features (pure ECMAScript,
for the most part) [consists of the Guide and the Reference].
It is definitely a reference about the Mozilla implementation(s) of JavaScript, which today covers all of EcmaScript 5.1 features. They're well documented, also containing information about bugs in older Mozilla implementations and in relevant other engines. Each article also lists cross-browser support in a table, though these are sometimes not correct and/or exhaustive.
The reference also includes documentation of proprietary Mozilla features and of their draft implementations for upcoming standards. These are properly marked as such, usually with the non-standard-tag.
Also, don't forget that it's a wiki!
as Alex K has said in his comment
It documents Geko, the mozilla implementation of JS which also includes all the non-standard functionality they have included
It is also an excellent reference for standard js api calls, but should always be used with a slight caveat of, it is the Geko implementation so may not behave as described, but generally it does in my PERSONAL experience
Looking through the Mozilla JavaScript site, I see that JavaScript 1.8 has a lot of great functions. In most cases it has code you can add to extend prototypes of the basic types in the case that the function is not implemented on the user's browser. Is there a library that you can use to add all those functions and therefore use JavaScript 1.8 freely in your code?
You are probably looking for a shim.
Check out the es5-shim: https://github.com/kriskowal/es5-shim/
Modernizr has a pretty exhaustive list (wiki) of alternative polyfills or shims (look under ECMAScript 5 for your needs):
https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills
Also, not all features can be provided by shims or polyfills. You could start an issue (remember to search and read the README first) for a feature that you want but isn't provided and the developer might tell you if it's not possible.
Since this version has lots of syntax differences (mentioned by Rob W), there are only two way this can be done
Somebody would have to write a JS interpreter in JavaScript, which would be good awful slow.
Write a server side compiler that turns JavaScript 1.8 into EcmaScript.
No, there isn't one out there.
I want to know which sites can give me information on the list of JavaScript functions that are supported by IE/Firefox/Opera/Safari.
Take a look at quirksmode
and in the Compatibility Master Table
you will get a detailed listing.
Perhaps not a direct answer to this question, but never-the-less I think this is useful to know about: You can use the Sputnik JavaScript Conformance tool in Google Labs to check ECMAScript conformance in browsers:
Sputnik is a JavaScript conformance
test suite containing over 5000 tests.
It tests how well a JavaScript
implementation adheres to the ECMA-262
specification version 5, looking only
at those features that were also
present in the previous version,
version 3, and not the new features
added in version 5.
There are several sites for that but you'll probably find that none are absolutely complete, so it is worth checking out each of them
quirksmode.org compatibility tables
sitepoint JS reference (work in progress)
Mozilla MDC reference (mozilla only but worth mentioning)
This looks useful http://kangax.github.com/es5-compat-table/