-
Notifications
You must be signed in to change notification settings - Fork 16
ES6 and ES7
Fred Chien edited this page Sep 30, 2015
·
3 revisions
Lantern is widely using ECMAScript 6 and 7, so you might need to know a little bit before working on your new service. We wrote down comparison here for your reference.
Traditional:
var foo = require('foo');
ES6:
import foo from 'foo';
Traditional:
module.exports = {};
ES6:
export default {};
Traditional:
function() {
// Do something...
}
ES6:
() => {
// Do something...
}
The generator is a new feature in ECMAScript 6, it provides a special function which can be exited and later re-entered. Node.js 0.12+ and io.js natively support such syntax, but browser supports it by using babel.
All of route handlers of Koa are using generator
function *() {
// Do something...
}