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

84

u/uberpwnzorz Dec 17 '18

you need to use bind so the log function keeps the context of console.

const print = console.log.bind(console)

6

u/jetpacmonkey Dec 17 '18

Is this still true in every browser? I've noticed in Chrome that I can do promise.then(console.log), and I'm pretty sure that didn't work a few years ago.