What is Nostr?
Aral Balkan /
npub1nk5…mz64
2025-01-09 17:29:55

Aral Balkan on Nostr: Oh my goodness, how did I miss that in ES7 you can use a closure as a method. Goodbye ...

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! :)

#JavaScript #EcmaScript7 #ES7 #closures #classes #methods #bind #functions
Author Public Key
npub1nk5eg4jm9ucsptghzsyq6zq6jrrhrwdmzfmdjwtetadfu9u6lq5szvmz64