Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Call and apply are core concepts to writing good javascript. I would not hire someone (at least for any sort of senior role) that could not tell you exactly how both of them work. Many of the other things on this page are certainly "trivia" that could be addressed by google when they come up, but not those.


>Call and apply are core concepts to writing good javascript.

But the biggest issue is the disagreement with the body of knowledge that everyone should have. Even in the body of knowledge, there's disagreements about what bits of knowledge go to which categories (Is it nice-to-know, or need-to-know?)

It's really no wonder you see such a broad range of candidate skills and knowledge. The sub-fields of the programming field can't even decide what everyone ought to know at various levels of experience!


How often do you use call and apply? I've been a JS developer for a long time, have written a lot of JS code, and rarely need to use call and apply.

Unless you're writing all your code from scratch and not using any frameworks / util libs (which you should) you won't need them very often.


Agreed I can't even recall the last time I used call or apply. We might have only a handful of cases out of roughly 200,000 JS lines of code.


Perhaps that is why y'all have 200k LOC of javascript :)


Fairly often. Since the selected DOM element is the value of this in any event handler callback, you can migrate out the function and use it for different things (i.e. validation of, say, autofill after a settimeout) and different contexts with call/apply.


I don't see how this requires you to know the intricacies of call/apply or how it would even force you to use it frequently enough to understand the difference.


I guess I don't understand. There's a lot of ways to accomplish tasks in any programming language but in JS in particular there's a way to assign the value of this and you can use it to have clean, dry code, and I'd expect any sr. level people to know how to use it. jQuery source has over 100 uses of call and apply.


> jQuery source has over 100 uses of call and apply.

Right, jQuery does it for you. You usually don't need to do it yourself unless you're contributing to jQuery (or another lib/framework that needs them).

I might ask someone about call and apply but wouldn't be overly concerned if they didn't remember the exact syntax or mixed them up. I've done the same myself. I wouldn't expect someone to remember every little nuanced part of a language, especially if it's not something they use frequently.


If you do meta-programming in JavaScript you use call/apply all of the time.


I agree, but I'll say that it wasn't until I started writing non-ember application code (switching to react + immutable.js + pure functions) that I needed things like call / apply / bind on the regular. So writing framework code can really insulate you from needing these things, not implying that that's a bad thing, but personally writing regular javascript has been a breathe of fresh air.


Well, they are both exactly the same. The only difference is the particular way each accepts arguments, and it's easy to forget which is which. So yes you should know how they work, but the distinction between them is contingent and difficult to remember.


Like most JS concepts, to me it's a "use it or lose it" situation. When I have to use them they are fresh in my head, when I move on to another project for 6 months that has no complex modules or uses a framework like Angular, there is no way I'll remember the intricacies. That being said, there is still a different between having used them and simply being aware of their existence, which I suppose could be made clear during an interview.


This sounds like a very good answer to that question.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: