Artboard 16light, inspiration, solution, idea, innovation,Google Sheets iconSwift icon
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. ;)

Related Topics

Related Articles