Why doesn't Strict Mode throw Syntax Error on duplicated property names?

Viewed 24

In JavaScript, Strict Mode is supposed to throw Syntax Error if we try to define object with duplicated properties, like this:

const foo = {a: 1, a: 2};

Call me crazy, but I remember it did. Today I was in shock to find out that it doesn't at least in newest Chrome and Firefox on macOS.

function crazy() {
    'use strict';

    const badboy = {a: 1, a: 2};

    return badboy;
}

console.log(crazy().a); // prints 2

What happened?

0 Answers
Related