Request: Apply arguments on .bind()
See original GitHub issueAllow applying arguments on .bind()
.
function one(foo) {
console.log('Got foo:', foo); // should print 'go'
console.log('Got context:', this.a); // prints 'lol'
}
Promise.resolve()
.bind({a: 'lol'}, 'go')
.then(one);
Issue Analytics
- State:
- Created 9 years ago
- Comments:24 (5 by maintainers)
Top Results From Across the Web
How to Use the Call, Apply, and Bind Functions in JavaScript
In this article, I am going to explain how to use call, apply, and bind in JavaScript with simple examples.
Read more >Javascript: call(), apply() and bind() - Medium
When we use the bind() method: the JS engine is creating a new pokemonName instance and binding pokemon as its this variable. It...
Read more >Learn & Solve : call(), apply() and bind() methods in JavaScript
The bind() method creates a new function where “this” refers to the parameter in the parenthesis in the above case “car”. This way...
Read more >Function.prototype.bind() - JavaScript - MDN Web Docs - Mozilla
The bound function will store the parameters passed — which include the value of this and the first few arguments — as its...
Read more >Javascript call() & apply() vs bind()? - Stack Overflow
call and apply call a function while bind creates a function. Though with call() you pass arguments individually and apply() as an argument...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yea, I can’t disagree with you @phpnode, and that’s a good workaround… My only problem is that I always work with constructors and prototypes and the context needs to be there as is, intact (it can’t be a new Object) … or it’d be a new idiom of the type:
This discussion wouldn’t happen if V8’s
bind()
implementation wasn’t slow enough to justify it.I know I’m necromancing this feature request, but I’d love to see the initial suggestion implemented as well!