Shouldn't that err? I think you need console.log.bind(console). On mobile, can't test. I just don't want to give Java'rs anymore ammunition
Edit: Wow I've never been more excited to be wrong and to be down-voted. I'm not sure when this bug was fixed, but FOREVER this would have caused Illegal Invocation error. If you don't believe me, just search "console.log illegal invocation". Another one to throw on the "well, in my day..." pile. Yay!
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:
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.
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.
My favourite “in my day” was this IE6 bug that caused IE6 to lose the name attribute when manipulating form dom elements, they would never submit but would be visible in the developer toolbar. Trying to track this down pre-stackoverflow was a nightmare!
337
u/Pavlo100 Dec 16 '18
Here is the Java implementation for those who want to make their life harder