#List all 'globals' exposed by deno

1 messages · Page 1 of 1 (latest)

crimson dewBOT
#

I wasn't able to find the answer to your question in the official Deno documentation. However, based on your message, Object.getOwnPropertyNames(globalThis) should indeed list all the enumerable and non-enumerable properties, including console, on the global object.

If console or other expected globals are not showing up, it could be due to the environment in which you are running the code or a change in the implementation of Deno that isn't reflected in the documentation. It's also possible that there might be a bug or an edge case affecting the visibility of certain global properties.

Please note that this advice is not based on the Deno documentation, and I would recommend double-checking the accuracy of this advice. If you continue to experience unexpected behavior, you might want to reach out to the Deno community or file an issue on the Deno GitHub repository for further assistance.

fathom plank
#

All Deno basic are is under Deno, more are in their url of standard library https://deno.land/std

Things like console are in fact part of window

#

Weirdly enough, look at this:

> Object.getOwnPropertyNames(globalThis).includes('console')
false
> Object.getOwnPropertyNames(globalThis).includes('window')
true
> Object.getOwnPropertyNames(window).includes('console')
false
> window.console
Object [console] {
  log: [Function: log],
  debug: [Function: debug],
  info: [Function: info],
  dir: [Function: dir],
  dirxml: [Function: dir],
  warn: [Function: warn],
  error: [Function: error],
  assert: [Function: assert],
  count: [Function: count],
  countReset: [Function: countReset],
  table: [Function: table],
  time: [Function: time],
  timeLog: [Function: timeLog],
  timeEnd: [Function: timeEnd],
  group: [Function: group],
  groupCollapsed: [Function: group],
  groupEnd: [Function: groupEnd],
  clear: [Function: clear],
  trace: [Function: trace],
  profile: [Function: profile],
  profileEnd: [Function: profileEnd],
  timeStamp: [Function: timeStamp],
  indentLevel: 0,
  createTask: [Function: createTask],
  [Symbol(isConsoleInstance)]: true
}
#

Nevermind: Object.getOwnPropertyNames(globalThis).includes('console') returns true in Node and Bun but not in Deno 🤔

quartz cipher
#

deno run main.ts with

console.info(self.console)

returns

Object [console] {
  log: [Function: log],
  debug: [Function: debug],
  info: [Function: info],
  dir: [Function: dir],
  dirxml: [Function: dir],
  warn: [Function: warn],
  error: [Function: error],
  assert: [Function: assert],
  count: [Function: count],
  countReset: [Function: countReset],
  table: [Function: table],
  time: [Function: time],
  timeLog: [Function: timeLog],
  timeEnd: [Function: timeEnd],
  group: [Function: group],
  groupCollapsed: [Function: group],
  groupEnd: [Function: groupEnd],
  clear: [Function: clear],
  trace: [Function: trace],
  profile: [Function: profile],
  profileEnd: [Function: profileEnd],
  timeStamp: [Function: timeStamp],
  indentLevel: 0,
  [Symbol(isConsoleInstance)]: true
#

deno/runtime/lib.rs

pub use deno_console;