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.

0

u/spazz_monkey Dec 17 '18

There's a dude at my work who did this in production code.

self = this

16

u/_xiphiaz Dec 17 '18

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

1

u/alejalapeno Dec 17 '18

I prefer(ed) _this = this