Start working with EcmaScript 6 now! Babel

If you are a Front End Developer who loves Front End Stack and you want to be still up to date you have to start working with EcmaScript 6. Why? This is the future of this language and tomorrow you have one day of delay with ES6:)

Yes I can hear you now… “but this code is not working on old browsers” and … now Im giving you a link and 10 minutes to think. Dont hesitate!

So what you have to do?

Install Babel on your machine!

npm install -g babel

And now you can easily write your first code. When you finish it you can compile your file and see how it works in browser.

Add compiler with watcher for your file:

babel script.js --watch --out-file script-compiled.js

Now you can check how ES6 code compiles to ES5 code.

Configure gulp to work with your ES6 files

Firstly install babel for gulp:

npm install --save-dev gulp-babel

Then add a task to your gulpfile.js

var gulp = require("gulp");
var babel = require("gulp-babel");

gulp.task("default", function () {
  return gulp.src("src/app.js")

And everything is working now as you wished.

Work with ES6

There is a lot of tutorials about ES6 but you have to use it to learn it. Write your own tests to check what ES6 can give to you. It has a lot of new features so be ready for more fun and more reasearch.

My EcmaScript 6 tryout

Ive started to recreate my code in Geolocation.js.

Here you can check the source in ES6:

Here is compiled code (by Babel)