Equality of object property names depends on code units (#tilPost)

Today I was writing a quick blog post on hidden characters in object property names and while writing this I came across my learning of the day.
The ECMAscript spec describes equality for property names as follows:

Two IdentifierNa…


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis

Today I was writing a quick blog post on hidden characters in object property names and while writing this I came across my learning of the day.

The ECMAscript spec describes equality for property names as follows:

Two IdentifierName that are canonically equivalent according to the Unicode standard are not equal unless they are represented by the exact same sequence of code units.

This means that an object can have to properties that look the same but consist of different code units. So let's have a look at an example.

const unicodeObject = {
    ü: 'foo',
    u\u0308: 'bar'
}

// evaluates to:
// {ü: "foo", ü: "bar"}

The properties look the same but are actually not because they consist of different code units. If you're interested in more details on property names check out the blog post there is way more cool stuff in it. ;)


Reply to Stefan


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis


Print Share Comment Cite Upload Translate
APA
Stefan Judis | Sciencx (2023-02-09T02:47:19+00:00) » Equality of object property names depends on code units (#tilPost). Retrieved from https://www.scien.cx/2017/07/15/equality-of-object-property-names-depends-on-code-units-tilpost/.
MLA
" » Equality of object property names depends on code units (#tilPost)." Stefan Judis | Sciencx - Saturday July 15, 2017, https://www.scien.cx/2017/07/15/equality-of-object-property-names-depends-on-code-units-tilpost/
HARVARD
Stefan Judis | Sciencx Saturday July 15, 2017 » Equality of object property names depends on code units (#tilPost)., viewed 2023-02-09T02:47:19+00:00,<https://www.scien.cx/2017/07/15/equality-of-object-property-names-depends-on-code-units-tilpost/>
VANCOUVER
Stefan Judis | Sciencx - » Equality of object property names depends on code units (#tilPost). [Internet]. [Accessed 2023-02-09T02:47:19+00:00]. Available from: https://www.scien.cx/2017/07/15/equality-of-object-property-names-depends-on-code-units-tilpost/
CHICAGO
" » Equality of object property names depends on code units (#tilPost)." Stefan Judis | Sciencx - Accessed 2023-02-09T02:47:19+00:00. https://www.scien.cx/2017/07/15/equality-of-object-property-names-depends-on-code-units-tilpost/
IEEE
" » Equality of object property names depends on code units (#tilPost)." Stefan Judis | Sciencx [Online]. Available: https://www.scien.cx/2017/07/15/equality-of-object-property-names-depends-on-code-units-tilpost/. [Accessed: 2023-02-09T02:47:19+00:00]
rf:citation
» Equality of object property names depends on code units (#tilPost) | Stefan Judis | Sciencx | https://www.scien.cx/2017/07/15/equality-of-object-property-names-depends-on-code-units-tilpost/ | 2023-02-09T02:47:19+00:00
https://github.com/addpipe/simple-recorderjs-demo