How to compile Dart to JavaScript v 1.3? - javascript

We have written a lot of horrible jscript code for server side classic ASP (the current platform of some very big blue chip companies which are our customers). jscript is more or less javascript version 1.3. It doesn't have built in JSON libs, and doesn't have some of the newer loop constructs for example
The question is, can the dart JavaScript compiler target older versions of JavaScript?

No. See Q. What browsers do you plan to support as JavaScript compilation targets?.
We're currently aiming to support the following browsers:
Internet Explorer, latest two versions that are 9 or higher.
Firefox, latest two versions that are 7 or higher.
Chrome, latest version.
Safari, latest two versions that are 5.1 or higher.
Opera, latest version that is 12 or higher.
That's a goal; we don't actually support all of these browsers yet. The goal may change to be either more restrictive or more permissive. We'll refine this further as Dart matures.
I think the main reason is to have a browser that contains a quite recent version of javascript.
For instance, you can find some calls to Object.create (requires JavaScript 1.8.5) in the js file resulting of dart2js compilation.

Related

Can't use "let" keyword in Safari Javascript?

I don't understand the best way to use "let" keyword...
In IE11 and Chrome45 I can use it fine
In Safari8.0.4, like in older versions of Chrome, it gives the error "unexpected use of reserved word 'let'"
In Firefox the let keyword only works inside <script type="application/javascript;version=1.7"/>, but this script type isn't even recognized as Javascript in IE11, Chrome45, Safari8.
Here's a JSFiddle that shows it in action: https://jsfiddle.net/p6cgtyg6/1/
So -- I don't mind requiring users to use modern versions of their browsers.
And I don't mind excluding Safari if there honestly is no version of Safari that supports this keyword. (Is that really true? Why does everyone spend all their time griping about IE when Safari seems so much worse in ES6 terms? Have I missed something?).
But how should I allow "let" to work in Firefox while not preventing Chrome/IE? (I haven't yet found links from people griping about how Firefox script tag behaves differently from Chrome, and I'd have expected more complaints, so I figure I must have missed something obvious...)
Concerning Safari 8, it's just not supported ; for that browser, I'd recommend using Babel.
If you have the gut feeling that this bug won't be fixed anytime soon* then you could have a script that detect Firefox which would then inject your script(s) with the appropriate value for the type attribute.
As a side note, I would advise not to use let blocks—unless you wanna use this transpiler—nor let expressions which will be dropped.
* fixed in Firefox 44
let is a part of ECMAScript 6 specification, and ECMAScript 6 itself is in 'draft' status. Even in its incomplete form its features aren't supported fully by actual browser versions.
Since you want to dive into ES6 today for production, your best bet is to use ES6 to ES5 transpiler, most prominent ones are Babel and Traceur, which are available as both CLI and packages for the build system of your choice. There are online tools for Babel and Traceur to try them out. And Scratch JS extension for Chrome uses both Babel and Traceur and is excellent for developing and compiling ES6 scripts if the build system is not an option.
Here is up-to-date comparison table that embraces ES6 feature support in both browsers and ES6 compilers.
And here is a great collection of ES6-related tools.
See browser compatability of this ES6 keyword.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Browser_compatibility
Also see this SO post for ES6 feature detection.

Looking to switch to VS 2013/MVC for web development but need to support IE8

Our current development is in VS 2008 using WebForms and JQuery. We must support IE8.
For new projects I would like to start using VS 2013/MVC but I am not sure if support of IE8 will be an issue. I have used VS 2013 for short time on co-worker's PC and I noticed it includes JQuery, Bootstrap, modernizr-2.6.2.js and respond.js frameworks (of those I am only a bit familiar with JQuery) in project generated from MVC template. Note that I am fairly new to web development and JavaScript in particular.
JQuery used in this project is version 1.10.2 and 1.* JQuery branch supports IE8.
Bootstrap is v. 3.0.0 and IE8 support has some limitations as I found here: http://getbootstrap.com/getting-started/#support Are these a big deal/show stoppers? Are there workarounds?
Information I found on modernizr is not completely clear. On one hand this page http://modernizr.com/docs/ says: "We support IE6+, Firefox 3.5+, Opera 9.6+, Safari 2+, Chrome.". On the other hand the same page says: "If you don't support IE8 and don't need to worry about FOUC, feel free to include modernizr.js whereever."
As far as respond.js it seems there are some issues for which people usually find workarounds.
Are there any issues inherent to latest version of MVC itself (other than JavaScript component compatibility) that make it incompatible with IE8?
ASP.NET MVC 5 itself should not have any compatibility issues with IE8. The Javascript libraries might have issues, but that depends on the developer.
By using VS2013/MVC and their project template, you're not required to use Bootstrap, Modernizr or whatever they include. If you don't need it, you can just remove the references. You can also manually add-in an older version of the libraries, if they do support IE8.

Firefox 24 has javascript version 1.5

I can't seem to find any information, but i have Firefox version 24 and when i look at the version of javascript that it uses, i get version 1.5. This is giving me constant headaches because i should have the 1.6 version. I have many bugs and problems with my javascript code related to this problem.
Does anyone know why FF ships with version 1.5 and how can i get the 1.6? I allready lookt up the mozilla forums and developer network, but no help there.
All my other browsers, safari, chrome and opera have newer javascript versions.
See this fiddle:
JavaScript is the original name that Mozilla gave to the language (LiveScript really, but that's history now). All browsers implement ECMAScript, what we know today as JavaScript. JavaScript 1.x is the internal versioning of Mozilla's implementation of ECMAScript. You should be comparing supported features not different implementations of the language since they all implement the same standard, ECMA.

JavaScript versions later than 1.5 - why?

The Mozilla Foundation continues to add new language features to JavaScript. They're up to version 1.8 now where 1.5 was more or less the ECMA baseline.
However, Firefox is the only browser that supports the latest version and IE is firmly stuck at a 1.5-equivalent JScript.
What purpose do the Firefox-only extensions serve? Or are they just lying dormant until (and if) the rest of the browsers catch up?
Firefox, Thunderbird, and other XUL apps also have large portions of themselves written in JavaScript. A more featureful JavaScript means a better development environment for Firefox and other Mozilla apps.
Extending the language is a good idea, even if only one browser is doing it - eventually it will prove itself and be made into the standard at which time other browsers will have to catch up.
Otherwise, how can progress be made - Microsoft does this all the time: would XMLHttpRequest have ever made it into the standards if Internet Explorer wouldn't have implemented it first?
From the Mozilla perspective the purpose of these changes, except for adding more capabilities for use by web developers, is to lead up to JavaScript 2.0, that is being developed as the next revision of ECMA 262 (revision 4) TC39 workgroup.
Future browsers will support JavaScript 2.0. In the mean time, developers are invited to take advantage of these extra features - natively in Firefox and using JavaScript libraries that provide backward compatibility with Internet Explorer. I find this very useful.
Also, it may be interesting to note that Webkit (the engine developed by KDE and used by Safari, Chrome and several free software browsers) supports JavaScript 1.7.
The biggest reason at the moment for improved JavaScript is for extension writers, who need not worry about cross-browser compatiblity.
JavaScript is a trademark by Sun which was licensed to Netscape and is now held by the Mozilla Foundation. Microsoft has their own implementation of the language called JScript, but there are others (eg. DMDScript).
ECMAScript was an afterthought to add a common baseline to the various implementations. So it's only natural that language development continues outside the standards committee, which is free to add the changes pioneered by the implementors in future revisions of the standard (eg the array extras introduces in JS1.6 will be in ES3.1).

Google Chrome - JavaScript version

Which version of JavaScript does Google Chrome support in relation to Mozilla Firefox? In other words, does Chrome support JavaScript 1.6, 1.7, or 1.8 which Firefox also supports or some combination of them?
While Chrome will execute Javascript marked as "javascript1.7", it does not support JS1.7 features like the "let" scoped variable operator.
This code will run on Firefox 3.5 but not on Chrome using V8:
<script language="javascript" type="application/javascript;version=1.7">
function foo(){ let a = 4; alert(a); }; foo();
</script>
If you change language to "javascript1.7" and omit the type, it won't run with JS 1.7 features in Firefox 3.5. The type section is necessary.
This seems to be related to a general WebKit bug, https://bugs.webkit.org/show_bug.cgi?id=23097; it may be that Chrome emulates the Safari behavior even though it uses a different engine.
When asked about supporting JS 1.8 features, the V8 team said they were trying to track the version used in Safari so pages would act the same in both browsers.
This thread is still relevant. As of 2012, Chrome supports most of Javascript 1.6, not including string and array generics. It supports none of 1.7. It supports reduce and reduceRight from 1.8, all of 1.8.1, and Getters and setters and all the non-version specific things listed on this page. This page is linked from the Mozilla Developer Network, which specifies the versions of javascript, found here.
Google Chrome uses the V8 javascript engine, which currently states that it implements ECMA-262, 3rd edition. This would imply it supports at least version 1.5.
Here's a simple Javascript 1.6 feature Chrome (and V8 users, like node.js) won't run: for each … in
for each (variable in object)
statement
As it is JS 1.5 (per J c's answer) is the only version Chrome claims to completely implement.
In fact the Chrome team has mostly aimed for compatibility with Safari (most prominent Webkit user at the time), and refused features on those grounds.
Google Chrome supports up to Javascript 1.7:
<script language="javascript1.7">alert(1.7);</script> - Alerts
<script language="javascript1.8">alert(1.8);</script> - Doesn't alert
This is an old thread, however here goes. Google Chrome does not respond to the following
function foo(){
let a = 4;
alert(a);
}
foo();
hence it does not support JavaScript 1.7

Categories