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

Show parent comments

20

u/[deleted] Dec 17 '18 edited Dec 17 '18

Stop downvoting him, assholes.

This didn't work without binding up until, if I'm not mistaken, Node.js 8.x. I don't remember it causing any errors, if I remember correctly it used to silently fail (i.e. not print anything because the log function would simply log to global).

Then at some point log() didn't depend on console being it's this. I've never seen a single sentence of explanation why this was changed, I've never used this kind of aliasing in browser so I'm not even sure it's a Node.js console implementation bug or a V8 bug, nor how Firefox behaved before (doesn't need bind() now).

So he was right.

Edit: Ah, yes, just needed to scroll down and find another post re the same thing and presto:

https://chromium.googlesource.com/chromium/src.git/+/807ec9550e8a31517966636e6a5b506474ab4ea9

3

u/loopsdeer Dec 17 '18

Aw thanks for the defense! Ya I looked through the chromium and firefox bugs and it looks like these have been very quietly resolved within the past year and a half.

But as I said in my edit, this is just one more thing on the "in my day" category now. For those of us using JavaScript since before jQuery, that category is quite huge and ever-growing. It's actually kind of delightful to be wrong in this way.

7

u/[deleted] Dec 17 '18

I'm no Samaritan tho, just extremely irritated by immature Reddit behavior of downvoting people out of own ignorance. Downvoting non-abuse is bad enough, but this really makes my blood boil sometimes.

2

u/ESCAPE_PLANET_X Dec 17 '18

The more technical a sub is, the more the reflexive downvote behavior is present.

Especially in broad subs where I assume people are just full Dunning Krueger -ing it.