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
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.