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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.