简体   繁体   中英

Wrong Class Name Showing in console.log

In Node.js, I've created a class in which I'm logging instances of that class to the console during tests.

When I console.log(anObjectFromThatClass), the letters "Vo" precede the opening curly brackets of that object in the terminal's output.

Normally, I'd expect to see the class name preceding the curly brackets, but instead I see Vo {} . The actually class name does not have a "V" or an "o" anywhere in its name, nor does it extend another class having a "V" or "o" in its name.

I tried googling to see what "Vo" means, but couldn't find anything due to all the false positives of that search.

Due to policy, I can't post the actual class here. I realize I'm not giving you much to go on, but can you think of a reason why "Vo" would precede the curly brackets when console logging an instance of a class not containing 'Vo' in its name? Does it have something to do with some type of live view provided by the V8 engine to node.js?

I've tried to create a class that reproduces this behavior, for this post, but every class I create, simply logs the correct class name before the curly brackets. This code has a lot of promises and async await stuff going on, perhaps that can alter class-names outputted by console.log?

I should probably just be glad this code is working good and forget about the idiosyncrasies of console.log() . However, I remain very curious, so please tell me if you know what this 'Vo' means.

The letters that come before the logged object when it gets console.log ged will be the name of the class, as it's represented in the code that was run . It sounds like the code that gets run is different from your source code - perhaps it's minified in some way, resulting in the run code having a class Vo { or something of the sort, even if the source code uses class MyClass { .

If the code is run without minification or other transpilation, you'll see MyClass { instead of Vo { when the object gets logged.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM