Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138337

Why is passing function in parameters of another function is giving unexpected result in Javascript

$
0
0

Please find the code below whenever i am trying to run this one it's giving some random integer value why is that . Can someone explain what is happening in the output.

let user = {
 name: "John",
 sayHi: function(){
  console.log(this.name);
 }
}
let paramFunc = function(func){
 func();
}
paramFunc(user.sayHi);

Viewing all articles
Browse latest Browse all 138337

Trending Articles