solution_correct_way_to_use_ES6

by upigilam

JavaScript

// solution: 
ES6 is finalized, but not fully supported by all browsers (e.g., ES6 Firefox support). To use ES6, we need to use a compiler like Babel. You can run it as a standalone tool or use with your build system. There are Babel plugins for Grunt, Gulp and Webpack.

Here’s a Gulp example. Install the plugin:
$ npm install --save-dev gulp-babel
In gulpfile.js, define a task build that takes src/app.js and compiles it into the build folder:
var gulp = require('gulp'),
  babel = require('gulp-babel')

gulp.task('build', function () {
  return gulp.src('src/app.js')
    .pipe(babel())
    .pipe(gulp.dest('build'))
})