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

14

u/Asmor Dec 16 '18

This won't work. Or at least, it didn't used to work. I haven't tried it in a very long time.

You'd need to do print = console.log.bind(console).

0

u/[deleted] Dec 17 '18

[deleted]

2

u/Asmor Dec 17 '18

Honestly, it's even better to just not do this in the first place. If you're gonna screw with it, might as well wrap it in a function. That also gives you some extra control, like having a variable for debug level and silently eating logs below the level you care about.