Skip to content
This repository has been archived by the owner on Dec 17, 2018. It is now read-only.

Replace _new with smart use of bind #62

Open
daurnimator opened this issue Apr 13, 2017 · 0 comments
Open

Replace _new with smart use of bind #62

daurnimator opened this issue Apr 13, 2017 · 0 comments

Comments

@daurnimator
Copy link
Owner

bind is more powerful than I knew. It changes not just 'this' but also optionally prepends args.
new Array(1,2,3) can also be expressed as new (Function.prototype.bind.call(Array,null,1,2,3))(), and hence also new (Function.prototype.bind.apply(Array,[null].concat([1,2,3]))) or even just new (Function.prototype.bind.apply(Array,[null,1,2,3]));.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant