Published at
Updated at
Reading time
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. ;)

Was this TIL post helpful?
Yes? Cool! You might want to check out Web Weekly for more quick learnings. The last edition went out 5 days ago.

Related Topics

Related Articles

About the author

Stefan standing in the park in front of a green background

Frontend nerd with over ten years of experience, "Today I Learned" blogger, conference speaker, Tiny helpers maintainer, and DevRel at Checkly.