Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript The JavaScript 'use strict' Statement

No Error in Chrome/Firefox Console for Duplicate named property in an object in strict mode.

Hi,

Even though I have duplicate keys in var badObject = {zoo: "animals", internet: "trolls", zoo: "keepers"}; I do not get this Uncaught SyntaxError: Duplicate data property in object literal not allowed in strict mode in Chrome 47.0.2526.73 (64-bit) & Firefox 42.0. However, I get an error when testing the same on Safari Version 8.0.8 (10600.8.9).

Why is that?

3 Answers

akak
akak
29,446 Points

In ES6 duplicated object literal is allowed in strict mode. Chrome and Firefox implemented that part of specification, Safari not yet.

Here's an answer why it's allowed now: http://stackoverflow.com/a/30617831/5367597 Cheers!

I believe that the zoo key value gets replaced with keepers and ignores the initial animals value.

Thanks akak.