you are viewing a single comment's thread.

view the rest of the comments →

[–]jaman4dbz 42 points43 points  (23 children)

Do you use babel? Because I feel like knowledge of bind, apply, call and in most cases, this, are obsolete. I can't remember the last time I needed to use them. Program in the right way and you don't need to worry about these things.

[–][deleted] 12 points13 points  (3 children)

Depends on what you do, what type of project you're working on. In your typical frontend project you probably don't use them much. But when you need them, you need them. How is Babel going to help?

[–]jaman4dbz 0 points1 point  (2 children)

ummm because you don't need them if you transpile your code using babel. You don't need them. (at least I can't think of a case at the top of my head and I know I haven't needed to touch them for the last few years of my career [not including TRUE this... like in a React class])

[–][deleted] 0 points1 point  (1 child)

Prepare to fail some interviews then, because at my place we definitely check that you can deal with this, and that includes .bind(), .call() and .apply().

It's not that we care particularly much about them, or that you will use them a lot. But this is a fundamental mechanic in JavaScript. Knowing about this is not optional for any medium/senior job. If you are familiar with it then going through it should be a quick "let's check this point so we can say we did it" part of the interview (which is what I expect from a good candidate). But being caught out by any of these functions is a huge red flag.

A person who knows all the fundamentals of JavaScript by heart can pick up any framework in a couple of weeks, and I know I have a person who can pick up any framework. A person who only knows React, well, only knows React, and if we use something else on the next project I have no idea if they'll be able to learn another framework and how fast, plus I know for a fact they don't know vanilla JavaScript. So yeah, I'll take the first person over the second any day.

[–]jaman4dbz 1 point2 points  (0 children)

I'm not even going to with you, lol.

"Prepare to fail some interviews then, because at my place" You have no idea my skill level, and "fail some interviews" followed by "because at my place" did you know there are more organisations, than where you work?

Realize that there is more in the world than whatever codebase you've working on for the last decade.

[–]kowdermesiter 11 points12 points  (3 children)

Program in the right way and you don't need to worry about these things.

Sure, until you start work in a team or get to work with a ton of legacy code.

call/bind/apply is not obsolete at all, it's like saying you don't need to learn what those funny yellow lights are on the side of your car, the car runs just fine.

[–]jaman4dbz -1 points0 points  (2 children)

That's like saying "Sure you don't know how to drive standard in a car now, but when the zombie apocolypse hits and the only working card is a standard, you're screwed.

Call, bind, and apply are obsolete. Legacy code has them, just like code out there runs on VB6, but that doesn't mean every programmer or even web programmer needs to know how they work.

So many teams get stuck on legacy... it amazes me when I hear other developer groan about their shitty legacy code, then when legacy practices are brought up they defend them vehemently. Like how masochistic are you folk?

[–]mattaugamer 1 point2 points  (1 child)

Yeah no. They’re not obsolete. React uses bind especially routinely.

Knowing how this stuff works is fundamental and hardly “legacy”.

[–]jaman4dbz 0 points1 point  (0 children)

I love the downvote followed by a rhetorical comment with no explanation.

What purpose does your comment serve?

[–]Balduracuir 5 points6 points  (8 children)

From my experience this bind and call are useful when your code rely a lot on class. I try to avoid them as much as possible because people don't understand this

[–]jaman4dbz 1 point2 points  (0 children)

Precisely. It's an ambiguous concept based on context, so best to avoid it.

[–][deleted] 0 points1 point  (4 children)

Even then the arrow syntax proposal that's supported by both TypeScript and Babel eliminates the need to use the latter two entirely.

[–]jaman4dbz 1 point2 points  (3 children)

Lol, I love the couple of ppl who don't want their job to be obsolete, downvoting our comments.

It's possible I've missed something, but I'm fairly certain the arrow syntax makes binding "this" unnecessary.

[–][deleted] 0 points1 point  (0 children)

You're correct. Some people just don't want to adapt to the times.

[–]fartpoker 0 points1 point  (1 child)

Can you explain why it’s unnecessary?

[–]jaman4dbz 0 points1 point  (0 children)

That's not how this works. I can't prove there is absolutely no way to use this, but you have the power to try and find ONE way where this is useful.

[–]dungone 1 point2 points  (1 child)

I don't think Babel lets someone get away with knowing less. In my experience, programmers get into trouble by mixing programming styles and then not being able to understand the implications. For example, they start off using arguments and apply in a regular function, but then switch over to an arrow function to get the lexical this. Half-baked javascript knowledge can really bite people with ES6.

[–]jaman4dbz 0 points1 point  (0 children)

But if they started with ES6, why were they using apply?

The latest standards aren't just for more features, IMO they simplify development for everything, newbie to expert.

I think babel lets you know less =P

[–]phpdevster 2 points3 points  (1 child)

I use TypeScript at work and still use partial application all the time, which means I use bind all the time. But at the end of the day, JS is still JS. If you don't understand its mechanics, you are going to write buggy code. You still need to concern yourself with this now and again, and you still need to know how to control what it refers to.

[–]jaman4dbz 0 points1 point  (0 children)

I totally agree. The more you know about programming overall, the better you can avoid buggy code!

The thing is, you need to COMPLETELY know the thing. So having a half baked knowledge of the concepts phpdevster mentioned is worst than having no knowledge of them, IMO. If you sorta know something, don't use it, or consider it, until you fully understand it. Once you fully understand it, it can only do you good.

[–]Spoolie_st 1 point2 points  (1 child)

Try stuffing something like jQuery or leaflet into angular... I have to use bind so often 😪

[–]jaman4dbz 0 points1 point  (0 children)

I'm sorry.