Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
bluepnume
on July 9, 2021
|
parent
|
context
|
favorite
| on:
How JavaScript Works: deep dive into call, apply, ...
Show me some code you can only write using either call, apply, or bind.
wruza
on July 9, 2021
[–]
Anything that substitutes ‘this’ but doesn’t want to put a function into that object.
const {filter} = [] class Foo { less() { return filter.call(this, sometest) } }
There is no way to closure it somehow without (temporarily) modifying an instance of Foo. (The next obvious question is “why” and the answer is “metaprogramming”.)
bluepnume
on July 10, 2021
|
parent
[–]
I would rather re-implement `filter` in a way that is specific to `Foo`, than to attempt to use an array method on my class.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: