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

what happening here in my code ?

hey when today i m revising javascript arrays i face a problem

// first code
var name = ["Ashish","Rohan"];
alert(name[0]);
//alert display A as a name[0]

//second code
 var names=["Ashish","Rohan"];
  alert(names[0]);
//alert display Ashish as a name[0] what the reason for two distinct answers

1 Answer

Hi "name" is a reserved keyword in Javascript. You should avoid to use these for variable and function names. name is used as a property in javascript language. Thats why "names" worked correct and name not. This site might help you: http://www.w3schools.com/js/js_reserved.asp