Can someone explaind what is happening here?
var dog = {
name: "Dogo"
}
var echo = function() {
console.log(this);
}
dog.echo = echo.bind(this);
echo();
dog.echo();
The first echo()
prints out the global object as expected.
However the second one prints empty object {}
isntead of what the first echo()
printed. Why?
Edit: Sorry! I didn't mention that the code is run by nodejs interpreter!
Thank you for help.