eupolicy.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
This Mastodon server is a friendly and respectful discussion space for people working in areas related to EU policy. When you request to create an account, please tell us something about you.

Server stats:

215
active users

#ecmascript7

0 posts0 participants0 posts today

Oh my goodness, how did I miss that in ES7 you can use a closure as a method. Goodbye `bind()`, you will not be missed :)

e.g.,

```js
class A {
b = () => console.log(this)
}

const a = new A()
a.b() // A { b: [Function: b] }

const c = a.b
c() // A { b: [Function:b] }
```

Nice! :)

**Edit**: Be careful with this. See this note by @marsup: mastodon.social/@marsup/113799

MastodonMarsup (@marsup@mastodon.social)@aral@mastodon.ar.al Respectfully, this looks like an anti-pattern. `b` won't be part of the prototype, potentially preventing some meta programming, and you're going to get a new `b` for each instance of that class, consuming that much more memory for each instance you hold.