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).

16

u/konaraddio Dec 16 '18

It works

I think you only need the .bind if console.log were to use this in its implementation

15

u/dvlsg Dec 17 '18

It used to need the bind. That was a recent-ish change, IIRC.