1. 程式人生 > >node.js打印function

node.js打印function

def javascrip 方式 stringify OS PE font -s end

var Person = function(name) {
this.name = name;
this.gender = [‘man‘, ‘woman‘];
}
console.log(Person);
console.dir(Person);
console.dir(JSON.stringify(Person));
console.log(typeof(Person));
console.log(Person.toString());

  

上面打印的結果:

[Function: Person]
[Function: Person]
undefined
function
function (name) {
   this.name = name;
   this.gender = [‘man‘, ‘woman‘];
}

  

可以采用toString()的方式對函數進行打印。

node.js打印function