Hacker News new | past | comments | ask | show | jobs | submit login

This is a perfectly straightforward implementation of a somewhat sophisticated concept.

But one wouldn't encounter this code in an application; this is library code. It's so useful and common that it's part of the ES5 standard (yes, ES5, not ES6). It might be the bind method from Prototype.js, but it's also the .bind method that all ES5 JS functions have.

Anyway, the question is not whether or not you should/coudl write this. The question is whether or not it's a good goal to be able to read this.

IMO, anyone who cannot read this function, albeit slowly and carefully, isn't an intermediate JS programmer, much less an advanced one.

Which of the concepts in this chunk of code is foreign to you? Prototypes? this? Using Array.p.s.c() to turn array-like args into an actual Array? shift? returning a function that, when called, invokes another function on the concatenation of one set of args with another set of args? This is all easy-mode stuff, unless you're brand new to JS, or you haven't bothered learning it.




I learned about all of this stuff by doing challenges on codewars.com




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: