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

When using a method, how to tell if the 'variable' or 'object' should be before the '.' or inside a set of parenthesis?

I'm kinda new to coding so I may not be using the correct terms but here's an example of what I mean:

var string1 = 'This is a string';

// displaying this in the console
console.log(string1);

// converting all characters to upper case
string1.toUpperCase();
  • How do I determine if the variable 'string1' should be used before the dot, as used in the 2nd method or inside a parenthesis like in the 1st method?

  • Do we just have to know it at the top of our heads or is there some sort of a hint?

Thank you!

It should be used before the dot like in the 2nd method. And no, every variable you use with toUpperCase();, you will have to put it before the dot. Everytime you are using a function like toUpperCase();, you put it behind the dot. But functions like console.log, you put in parenthesis.