Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view a function body in node.js?

Tags:

node.js

I only get [Function] when I try to display the function :

> var a = function(){ return 'toto'; }
undefined
> a
[Function]
> require('util').inspect(a)
'[Function]'
like image 328
Simon Avatar asked Jul 14 '12 07:07

Simon


1 Answers

Use toString:

> var a = function(){ return 'toto'; }
undefined
> a.toString()
'function (){ return \'toto\'; }'
like image 70
phihag Avatar answered Oct 25 '22 08:10

phihag