Google Releases JavaScript to Dart Translation Guide

Published Date
03 - Feb - 2012
| Last Updated
03 - Feb - 2012
Google Releases JavaScript to Dart Translation Guide

Google hopes to make Dart one of the official languages of the web; but before that is feasible it will need some fluent “speakers” first.

Dart is similar to JavaScript, so someone coming from the JavaScript world should not have too much trouble understanding it. Also, Dart in most can be used with a syntax similar to JavaScript; however this would not be taking advantage of the new features Dart brings. This is where Google’s JavaScript to Dart Synonym app comes in.

The JavaScript to Dart Synonym app compare common programming idioms in JavaScript and Dart, so people can can a quick reference for the best way to accomplish something in Dart if they know how to do it in JavaScript.

For example, in Dart typing is optional, so while you can declare a variable in the JavaScript way with var stringVariable = ""; it is better if you do the more descriptive String stringVariable = ""; instead. Also, since Dart supports string interpolation, so the following JavaScript example:

var name = 'Aaron';
var greeting = 'My name is ' name '.';

Can instead be written as:

String name = 'Aaron';
String greeting = 'My name is $name.';

The JavaScript to Dart Synonym app has dozens of such examples, including the ones above, that should help anyone transition from JavaScript to Dart.

For those who are looking for a JavaScript alternative, but aren’t satisfied by Dart, there are always other options.