05:25
<ryzokuken>
Since we don't specify console, dunno if it qualifies as a "namespace", but it's certainly like one and it's expose to JavaScript so...
05:25
<ryzokuken>
(just an example of a popular "namespace" that isn't PascalCased)
07:29
<Ashley Claymore>
Since we don't specify console, dunno if it qualifies as a "namespace", but it's certainly like one and it's expose to JavaScript so...

Personally I’ve thought of globalThis.console as a singleton instance with methods of the Console class

https://nodejs.org/api/console.html#console_class_console

07:31
<ryzokuken>

Personally I’ve thought of globalThis.console as a singleton instance with methods of the Console class

https://nodejs.org/api/console.html#console_class_console

Interesting, I'd been referring to the whatwg console spec, didn't think about this class. Is this class also implemented in browsers or is it just a Node thing?
07:32
<ryzokuken>
❯ node -e "console.log(console.Console)"
[Function: Console]
07:32
<Ashley Claymore>
yep you can do console.constructor in browsers. But can't actually use it
07:33
<ryzokuken>
❯ eshost -e "console.Console"
#### JavaScriptCore

TypeError: undefined is not an object (evaluating 'console.Console')

#### SpiderMonkey
undefined

#### V8
undefined
07:34
<Ashley Claymore>
console.Console is node. in browser's it's console.constructor
07:34
<ryzokuken>
ah, gotcha
07:35
<Ashley Claymore>
The constructor doesn't work, but is a hint that console is an instance
07:35
<ryzokuken>
you're right. The existence of console.constructor means it's an instance and not a namespace
07:35
<ryzokuken>
yeah
13:50
<ljharb>
it’s conceptually a namespace tho - “a singleton instance of a class whose constructor you can’t use” is just a misuse of a class :-p
13:51
<ljharb>
historically the receiver mattered, and you had to console.log.bind(console), but i don’t think you have to do that anywhere anymore
13:56
<Ashley Claymore>
Another instance like thing is that (in some hosts) it has state. With methods like groupStart and groupEnd
13:57
<Ashley Claymore>
I will admit that it is 'namespace-like' in a lot of ways
14:08
<Ashley Claymore>
it’s conceptually a namespace tho - “a singleton instance of a class whose constructor you can’t use” is just a misuse of a class :-p
Node allows more to be constructed, so more like a class there
14:11
<ljharb>
True enough
14:12
<ljharb>
it’s a weird one tho. the point about state in group and performance is a good one
14:18
<Ashley Claymore>
and the whatwg spec does say it's a namespace. So I could be convinced either way depending on the weighting of the different bits of 'evidence' 🙂
14:53
<ptomato>
I'd call it a historical oddity due to ad-hoc decision making, myself
16:56
<bakkot>
see #whatwg: https://matrixlogs.bakkot.com/WHATWG/2021-07-14#L13