Re:How JavaScript Works: deep dive into call, apply, and bind
by bluepnume on Friday July 09, 2021 @07:14PM
(#27789559)
Show me some code you can only write using either call, apply, or bind.
[ Parent
| on HN ]
Re:How JavaScript Works: deep dive into call, apply, and bind
by wruza on Friday July 09, 2021 @07:48PM
(#27789745)
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”.)