在Node.js中,console对象上的上下文函数是什么?

在Node.js中,console对象上的上下文函数是什么?,node.js,Node.js,查看Node.js repl中的控制台对象,我看到它有一个上下文函数: > console Console { log: [Function: bound consoleCall], debug: [Function: bound consoleCall], info: [Function: bound consoleCall], warn: [Function: bound consoleCall], error: [Function: bound consoleCa

查看Node.js repl中的
控制台
对象,我看到它有一个
上下文
函数:

> console
Console {
  log: [Function: bound consoleCall],
  debug: [Function: bound consoleCall],
  info: [Function: bound consoleCall],
  warn: [Function: bound consoleCall],
  error: [Function: bound consoleCall],
  dir: [Function: bound consoleCall],
  time: [Function: bound consoleCall],
  timeEnd: [Function: bound consoleCall],
  trace: [Function: bound consoleCall],
  assert: [Function: bound consoleCall],
  clear: [Function: bound consoleCall],
  count: [Function: bound consoleCall],
  countReset: [Function: bound countReset],
  group: [Function: bound consoleCall],
  groupCollapsed: [Function: bound consoleCall],
  groupEnd: [Function: bound consoleCall],
  Console: [Function: Console],
  dirxml: [Function: dirxml],
  table: [Function: table],
  markTimeline: [Function: markTimeline],
  profile: [Function: profile],
  profileEnd: [Function: profileEnd],
  timeline: [Function: timeline],
  timelineEnd: [Function: timelineEnd],
  timeStamp: [Function: timeStamp],
  context: [Function: context],
  [Symbol(counts)]: Map {} }
调用此函数时,似乎返回一个类似于
控制台的对象
,但缺少一些内容:

> console.context()
{ debug: [Function: debug],
  error: [Function: error],
  info: [Function: info],
  log: [Function: log],
  warn: [Function: warn],
  dir: [Function: dir],
  dirXml: [Function: dirXml],
  table: [Function: table],
  trace: [Function: trace],
  group: [Function: group],
  groupCollapsed: [Function: groupCollapsed],
  groupEnd: [Function: groupEnd],
  clear: [Function: clear],
  count: [Function: count],
  assert: [Function: assert],
  markTimeline: [Function: markTimeline],
  profile: [Function: profile],
  profileEnd: [Function: profileEnd],
  timeline: [Function: timeline],
  timelineEnd: [Function: timelineEnd],
  time: [Function: time],
  timeEnd: [Function: timeEnd],
  timeStamp: [Function: timeStamp] }

> console.context() === console
false
虽然它看起来很相似,但功能不同:

> console.context().log('hello world')
undefined
这些项目位于
控制台中,但不在
控制台.context()中。

构造函数
控制台
计数重置
记录在

[Symbol(counts)]
对象可能与 实现
计数
计数重置

但是
context
似乎应该记录,而不是。是什么
它是控制台。上下文是为控制台输出创建新上下文的工具。它没有,所以应该是在V8中实现的

因为它是实验性的,所以可能会有不一致之处
console.context
在任何最新的Chromium版本中都没有像我预期的那样工作,并且它不应该在Node.js中提供有用的结果

Console: [Function: Console],
[Symbol(counts)]: Map {}
context: [Function: context],
countReset: [Function: bound countReset],