DEV Community

Discussion on: Can You Guess the Result of This JavaScript Code?

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

Yes, c - every subsequent property definition is overwriting the previous one.

Collapse
 
ludamillion profile image
Luke Inglis

For a little extra context here on why the overwriting occurs. Object keys can only be one of two things a String or a Symbol. All three definitions above result in a the String '1' being used for the key since anything that isn't a Symbol is coerced into a String.