Learning JavaScript 6

I am going to be using JavaScript 6 (ECMAScript 6) for my new project codename Bird.

One of the things I thought was interesting with ES6 is it’s new shorthand for defining a method (function) onto an object literal.

var person = {
    name: "Nicholas",
    sayName() {
        console.log(this.name);
    }
};

That will be equivalent to:

var person = {
    name: "Nicholas",
    sayName: function() {
        console.log(this.name);
    }
};

source: Understanding ECMAScript 6


Posted

in

by

Tags: