Jon Newton

March 4, 2021

ES6 Function Shorthand

I’ve decided to take a detour in the loc8r project and use Vue instead of Angular on the frontend. I’m spending time today running through the Vue 3 tutorial and bumped into Yet Another Cool Javascript Feature: function shorthand.

ES5 convention:
const app = Vue.createApp({
  data: function() {
    return {
      product: 'Socks'
    };
  }
});

ES6 convention:
const app = Vue.createApp({
  data() {
    return {
      product: 'Socks'
    };
  }
});

About Jon Newton

Pandemic programming and beyond! My Link Tree