00:00 | <bakkot> | and indeed typeof Object(Symbol()) === 'object' |
00:00 | <jmdyck> | ah, there it is, thanks. |
00:00 | <jmdyck> | I'm going to have to look at this more. |
00:01 | <bakkot> | however, boxed symbols do not have a [[Description]] internal slot |
00:02 | <bakkot> | they instead have a [[SymbolData]] internal slot, which holds the underlying symbol, which is what e.g. Symbol.prototype.description uses |
00:06 | <jmdyck> | So it looks like the only way to create a Symbol object is by invoking ToObject on a Symbol value. Is that right? |
00:11 | <jmdyck> | (e.g., there isn't an analogue to new Number(3) ) |
00:18 | <bakkot> | afaik yes |
00:18 | <bakkot> | same deal for BigInts, I think |
00:19 | <jmdyck> | And referring to Symbol() as "the Symbol constructor" is technically correct, but maybe misleading (same with BigInt). |
00:28 | <jmdyck> | i.e., it has a [[Construct]] internal method so satisfies the definition of "constructor", but if you invoke it, you just get a TypeError, same as if it didn't have a [[Construct]] method, so it's kinda tenuous to call it a constructor? |
00:33 | <jmdyck> | It looks like Symbol() and BigInt() are the only things described as constructors that nevertheless are "not intended to be used with the new operator". |
00:40 | <bakkot> | true, but otoh it's the only way I've ever heard anyone refer to it, so I'd be reluctant to change it |
00:41 | <jmdyck> | huh, interesting. |
16:11 | <ljharb> | it starts with a capital letter and its .prototype is the [[Prototype]] of the instances, that colloquially makes it the constructor even if you can’t new it |
16:12 | <ljharb> | All the DOM element constructors can’t be newed either, and they’re all still called constructors |
16:12 | <Ashley Claymore> | I think of it as a 'newless constructor' |
16:14 | <Ashley Claymore> | or a standard constructor like Number , except that if I try and create a Number object instance it very loudly says "I'm not sure you want to do that" |
16:14 | <Ashley Claymore> | s/Number/Symbol/ |
16:16 | <Ashley Claymore> | maybe in the future if there was ever direct support for #constructor then could say that's what is happening in the case of Symbol and BigInt |
23:14 | <Mathieu Hofman> | Does anyone know why the following syntax was not included when getters/setters were added? And has it ever been proposed?
|
23:16 | <Mathieu Hofman> | Alternative is to jump through defineProperty hoops, which is not very ergonomic (and hard to type right in TypeScript) |