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 Updates
APA

Stefan Judis | Sciencx (2017-07-15T22:00:00+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 ,<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 ]. 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 . 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: ]
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/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.