I have a scenario where in I want to print custom message on log of some method reference.
Say I have a function sum(){}
now on console.log(sum);
I want to log a custom message on console. How can we achieve that?
I have a scenario where in I want to print custom message on log of some method reference.
Say I have a function sum(){}
now on console.log(sum);
I want to log a custom message on console. How can we achieve that?
Like this
var sum = function(){};
sum.toString = function(){ return 'my custom message'; };
console.log(sum);