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

337

u/Pavlo100 Dec 16 '18

Here is the Java implementation for those who want to make their life harder

const System = {out: {println: console.log}};
System.out.println("why?");

37

u/loopsdeer Dec 17 '18 edited Dec 17 '18

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!

1

u/MRGrazyD96 Dec 17 '18

nope, absolutely no need for binding

4

u/loopsdeer Dec 17 '18

Well this is exciting! See my edit