Console logs do not have a level associated with them, so you have no way to run your app with only error logs, or with debugging information. That makes it easy to not only write bad logs, but to get to a situation where you can't remove a bunch of related but distributed logs without some effort. Basically, logging without levels and organisation leads to bad code hygiene.
He's adding complexity with almost zero benefit. You have to look at the definition to see exactly what it does. Don't change the code for something like that. Change yourself. If it were something more complicated from another language that's complex then that's great. Don't do it for trivial shit like this.
Someone else pointed out that not binding this may cause problems. So he possibly introduced bugs as well.
Yeah it's a joke, but no, you should never do this.
You're adapting for other people, not languages or compilers. If you're working on a team you have to take this attitude. If not, you're more free to do what you want.
This used to be super common when creating JavaScript libraries before modules and arrow functions; it was used to maintain a reference to the parent scope for use within a callback function
94
u/mishugashu Dec 16 '18
If I came across that shit at work, I'd
git blamein a heartbeat and tell you to never do that again.But if you're doing it in personal projects, more power to you, I guess. Nothing really wrong with it code-wise.