r/javascript • • Dec 16 '18

Coming from Python to JS NSFW

const print = console.log

I found my safe space.

607 Upvotes

156 comments sorted by

View all comments

94

u/mishugashu Dec 16 '18

If I came across that shit at work, I'd git blame in 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.

4

u/kchoudhury Dec 17 '18

He aliased a function and it is amply obvious what it does. What standard did he violate?

5

u/mrbojingle Dec 17 '18

none, some people are just anal.

4

u/vellian Dec 17 '18

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.

6

u/kchoudhury Dec 17 '18

"Change yourself"

I hate this attitude so much. Programming languages and compilers are there to work for us, not the other way around.

5

u/vellian Dec 17 '18

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.