Object method shorthand after initial declaration

Brian Blakely anewpage.media at gmail.com
Tue Oct 24 17:28:53 UTC 2017


Extend the method shorthand syntax beyond initial object declaration.

```js
const obj = {};

obj.foo() {...}
```

Equivalent 2015 syntax:

```js
const obj = {
  foo() {...}
};
```

This is nice for assignment to context:

```js
function Foo() {
  this.bar() {...}
  this.baz() {...}
}

const foo = new Foo();
foo.bar();
foo.baz();
```

Equivalent 2015 syntax:

```js
function Foo() {
  this.bar = function() {...};
  this.baz = function() {...};
}
```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20171024/8530184a/attachment.html>


More information about the es-discuss mailing list