Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I debug variable of [Function] type?

Tags:

javascript

Some functions are set into variables. And I want to debug what kind of function is set there? However that function can non be changed. In this situation, how should I debug?

var something = returnfunc(); //returnfunc() return function type object
console.log(something);

[Function]
like image 941
Harry Avatar asked Apr 13 '26 20:04

Harry


1 Answers

You can call toString in the function to get a string representation of the source code ;)

E.g.:

let fn = (a, b) => a + b; 
console.log(fn.toString())
// (a, b) => a + b
like image 109
Luan Nico Avatar answered Apr 16 '26 08:04

Luan Nico



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!