英文:
How hide output of console.log for object
问题
在Linux中,我在控制台日志中有如下关于对象的输出:
代码: console.log('PGN=======', pgn[z], '\n');
控制台: PGN======= ElementHandle {}
这是我需要的,只是提供对象存在的信息。
而在Windows中,对于同样的代码,我在控制台日志中得到以下输出:
控制台:
PGN======= ElementHandle {   _disposed: false,   _context:
ExecutionContext {
    _client: CDPSession {
      eventsMap: [Map],
      emitter: [Object],
      _callbacks: Map(0) {},
      _connection: [Connection]
      _targetType: 'page',..........
      和许多其他行 }
这是我不需要的。如何在Windows中禁止这种输出?
英文:
I have strange problem for me, for my little experience.
In linux i have this output in console.log for object:
code: console.log('PGN=======', pgn[z], '\n');
console: PGN======= ElementHandle {}
And this what me need, just info that the object exists.
In Windows i have this output in console.log for object (same code):
console:
 PGN======= ElementHandle {   _disposed: false,   _context:
 ExecutionContext {
     _client: CDPSession {
       eventsMap: [Map],
       emitter: [Object],
       _callbacks: Map(0) {},
       _connection: [Connection]
       _targetType: 'page',..........
         and many other lines }
And this what me not need. How this suppress in Windows?
答案1
得分: 1
你可以使用以下代码
console.log(pgn[z].constructor.name);
(适用于原始数据类型)。
<details>
<summary>英文:</summary>
You could go
console.log(pgn[z].constructor.name);
(works for primitives as well).
</details>
				通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论