Published at
Updated at
Reading time
1min
This post is part of my Today I learned series in which I share all my web development learnings.

Today I was writing a quick blog post on hidden characters in object property names, and while writing it I came across today's learning.

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.

An object can have two properties that look the same but consist of different code units. Let's look at an example.

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

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

The properties look the same but are not because they consist of different code units. If you're interested in more details on property names, check out my blog post "Hidden messages in JavaScript property names", there is way more cool (and scary) stuff in it. ;)

If you enjoyed this article...

Join 5.5k readers and learn something new every week with Web Weekly.

Web Weekly — Your friendly Web Dev newsletter
Reply to this post and share your thoughts via good old email.
Stefan standing in the park in front of a green background

About Stefan Judis

Frontend nerd with over ten years of experience, freelance dev, "Today I Learned" blogger, conference speaker, and Open Source maintainer.

Related Topics

Related Articles