Skip to content

JSON cannot be a subset of JavaScript #1681

Description

@erights

In reforming the JavaScript treatment of \u2028 and \u2029, we frequently described the rationale as ensuring that JSON is a proper subset of JavaScript. Indeed, this brings it much closer. But we cannot repair the remaining discrepancy:

[{"__proto__": []}]

As JavaScript, this makes a singleton array whose element inherits from an empty array. As JSON, this makes a singleton array whose element inherits from Object.prototype and has an own data property named __proto__ whose value is an empty array.

Because of this, JSON will forever only approximate a subset of JavaScript.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions