I have been testing some code lately trying to understand javascript a little bit better. Then I came across the call() function wich I can't get to understand well.
I have the following code:
function hi(){
console.log("hi");
}
var bye = function(param, param2){
console.log(param);
console.log(param2);
console.log("bye");
}
If I call bye.call(hi(), 1, 2), I get hi 1 2 undefined
And if I call bye.cal(1,2), I get 2 undefined bye undefined
for which I understand the call() function first parameter has to be a function, followed by the amount of parameter my bye function accepts. But where is the last undefined coming from?