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 trialDavid Service
12,928 PointsUsing a Quotes with Sub-Scripting
Hi Everyone,
I've picked up the concept of subscripting pretty well, but wanted to verify something.
At 7:43 in this video, Jim uses a string to call upon the "log" command for the object he's working with:
console["log"](me);
From the previous video (about Arrays), I noticed that he did not have to use quotes for defined values (i.e. 0) or for variable names.
Since "log" is a property of the "console" function, I'm assuming that we only use quotes with proper words and not with defined values or variables. Is this right?
Thanks in advance,
David
shezazr
8,275 Pointsshezazr
8,275 PointsNumbers don't need quotation marks, and neither do the variables.. if you had an array with key of say dog you could do
//pseudo code alert(array['dog']) or animal = "dog" alert(array[animal])