2 ms·
That's a good summary. IMO just because a regex is callable does not mean it should be omitted (despite the spec). If it can be serialized in a proper way then
by ars 17y ago
That's a good summary.
IMO just because a regex is callable does not mean it should be omitted (despite the spec). If it can be serialized in a proper way then go ahead. (I know it has other properties, but just emitting /foo/ would be fine with me.)
A RegExp is probably a special case. The browsers should do the useful thing, and request an errata on the spec.
Wait, are they talking about the global RegExp object, or a specific RegExp?
And they should fork this bug into one just about RegExp.
- kangax 17y agoThey are talking about any `RegExp` object (technically, any object with "RegExp" [[Class]])
- gjm11 17y agoSerializing a regexp as, say, "/foo/" would mean emitting alleged JSON that doesn't conform to the JSON grammar in the spec, and that existing JSON parsers might be completely unable to do anything with. It might make some sense to change the spec to include regexp literals, but while the spec says what it does it would be unresponsible for any browser's stringify implementation to emit things that others' parse implementations might barf on. (It's a pity that JSON isn't more easily extensible in a backward-compatible manner. On the other hand, it's not clear how that could have been enabled without breaking the it's-just-a-subset-of-JS-literal-syntax principle.)