I'm fairly new to JavaScript (learning Node.JS) but I've been coding in OOP languages for quite some time. I feel like I understand most JS concepts but I'd love to learn more about this feature that has my mind boggled.
How does the argument binding work in this? How does console.log() get data here? Does this only work if there is only 1 default argument?
function processResponse (res) {
res.on('data', console.log)
res.on('error', console.error)
}
What is it called when the callback function doesn't need to be explicit about the argument it receives? Is it related to Function.prototype.apply()
/call()
/bind()
? Just wanted to further my understanding.
EDIT: I do realize that functions references can be passed around. I was wondering how console.log
receives its arguments here (what is the behind-the-scenes mechanism)