Sunday 11 June 2017

node.js console.log different output format for the same object

For the following code:

function F() {
}

// Define class fields for F
F.value = [ 1, 2, 3, 4 ];

console.log('F', F); // F function F() { }

console.log(F);      // { [Function: F] value: [ 1, 2, 3, 4 ] }

In the code above, I have define class fields for the constructor F. When I console.log() in node different argument list, the printing result is different for F. So that's why?
My node version is v4.2.6 and linux.

Thanks in advance.



via zhenguoli

No comments:

Post a Comment