while working through learnyounode, I found something that I would like some insight on from more experienced developers.
Consider this:
var http = require("http")
http.get(process.argv[2], (response) => {
var collectData = []
response.on("data", collectData.push) // does not work
response.on("data", console.log) // this works
// this works and is what I am using right now
response.on("data", (data) => {
collectData.push(data)
})
}).on("error", console.error)
As you can see, when a response.on event occurs, it passes the data to the console.log function but not the Array.push function.