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 trialcory kelly
2,762 PointsDoes javascript object allow for duplicate keys?
Does JavaScript object allow for duplicate keys, if not how would you add keys that have the same name but different values?
Thanks!
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsSorry, misread your question.
No, JavaScript objects cannot have duplicate keys. The keys must all be unique. There is a good thread on Stack Overflow on this topic.
(It is titled with 'associative array', but it really is about a JS Object).
cory kelly
2,762 Pointscory kelly
2,762 PointsThanks for the help! So if I use unique identifiers, what is the best syntax for that? pipeLength1: pipeLength2:
is their a better way than this?