
Destructuring and spread syntax – one of the most flexible ES6 features In the fitlerBySize computed property, we need to declare a variable size so this value can be used in the filter callback: new Vue() #4. In the below example, size is a data property. You can’t then refer to ES6 features of the Vue object as this.vueProperty from within the callback, you have to manually create them somewhere in the scope of the callback. If you use a regular function for a callback, however, it will bind its own value for this. Array filter, for example, allows you to return a new array only including those items that match the filter defined by the callback. Consider JavaScript array methods requiring a callback function. Instead, they use this of the enclosing context. An important feature of arrow functions is that they do not bind a value for this. They provide a shorter syntax, but differ from regular JavaScript function in other ways, too. These are a new way to declare JavaScript ES6 features. Arrow functions – one of the most prominent ES6 features These make use of JavaScript modules, but also require a build tool like Webpack.

Import component1 from './component1.js' Īn even better option for modularizing your components is to utilize Single-File Components. We can now import the component definition object now in our main file: app.js

Using modules, we can put our component definitions in separate files and achieve better organization. Pre-ES6, we’d need to put all our component definitions in the main file including our Vue instance. One great use case for module files is a component. Using JavaScript modules, we can do it with export and import syntax. How do you load a JavaScript object from one file into another? There was no native way to do it pre-ES6. So now, we – ArrowHiTech would like to introduce to you guys some essential explanations of ES6 features, along with the examples for Vue JS development. The sooner you get to know about that, the better your development will be obviously. Also, as a means of triage, you might start with those features that apply to Vue specifically. However, a few of its features are specifically suited to solve problems that arise when developing with Vue.js. Also, if you are a Vue.js developer, this specification will benefit a lot to you and your business when you get to know and learning it. So, if you’re new to JavaScript or haven’t updated your JavaScript knowledge recently, there are a number of new ES6 features that make development much better and more enjoyable. ES6 (a.k.a ES2015) is the current specification of the JavaScript language.

