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 Personally I’ve thought of globalThis.console as a singleton instance with methods of the Console class |
07:31 | <ryzokuken> |
|
07:32 | <ryzokuken> |
|
07:32 | <Ashley Claymore> | yep you can do console.constructor in browsers. But can't actually use it |
07:33 | <ryzokuken> |
|
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 |
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 |