Some quick notes on hand-converting from CoffeeScript to ES6/ECMAScript 2015 (e.g. for use with bablejs):
- add
'use strict';to beginning of file - add
letbefore new variable assignments, orconstif they are constant - add semicolons to end of statements (optional)
- add commas between elements of multi-line array literals
- add parenthesizes around function calls
- add braces around blocks
- replace
(args) =>with(args) => {arrow functions - replace
for x in awithfor (let x of a) { - replace
#with//comments - replace
==with===and!=with!==strict equality comparison - replace
"#{x}"with backquote template strings
`${x}`
- replace suffixed if/unless with prefixed if
- replace expression
if x then y else zwith ternary operatorx ? y : z - replace
class Foowithclass Foo { - replace method declarations
m: () ->withm() { - replace class method declaration
@m: () ->withstatic m() { - replace class variable declaration
@x = ywith static property getterstatic get x() { return y; } - replace
@instance variables withthis. - replace
andwith&&,orwith||,notwith! - replace
x ? yexistential operator withtypeof(x) !== 'undefined' : x : y - replace coffeeify browserify transform with babelify
- ...
note: these are simplified shortcuts, use with caution. references: