MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/a6txtp/coming_from_python_to_js/eby33yp/?context=3
r/javascript • u/chroner • Dec 16 '18
const print = console.log
I found my safe space.
156 comments sorted by
View all comments
14
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).
print = console.log.bind(console)
16 u/konaraddio Dec 16 '18 It worksI 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. 10 u/konaraddio Dec 17 '18 Oh, you're right, changes made in Chromium in 2016
16
It works
I think you only need the .bind if console.log were to use this in its implementation
.bind
console.log
this
15 u/dvlsg Dec 17 '18 It used to need the bind. That was a recent-ish change, IIRC. 10 u/konaraddio Dec 17 '18 Oh, you're right, changes made in Chromium in 2016
15
It used to need the bind. That was a recent-ish change, IIRC.
10 u/konaraddio Dec 17 '18 Oh, you're right, changes made in Chromium in 2016
10
Oh, you're right, changes made in Chromium in 2016
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).