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 trialMax van den Berge
6,506 PointsUppercase and lowercase letter Function.
Hi all,
I have a question, i noticed that some build-in JS function start with an Uppercase letter and some with a lowercase letter.
for instance: alert(); or document.getElementById(id); start with a lowercase letter
and
Math.random (); starts with an Uppercase letter.
can someone help me to understaind when it starts with an Uppercase letter or with a lowercase letter, since JS is case sensitive ?
kind regard and many thanks!
gr. Max
2 Answers
babyoscar
12,930 PointsUsually, built-in JavaScript functions start with a lower case letter. The upper case part of Math.random()
("M" in "Math") is actually the first letter of the object that has the function as one of its properties, not the actual function ("random" is the function). Hope this helped!
Clayton Perszyk
Treehouse Moderator 48,850 PointsIn the case of Math.random(), the method is called directly on the object (ie a static method). Other methods are called on an instance of an object (ie calling new to invoke a constructor).
Max van den Berge
6,506 Pointsthank you for sharing your knowledge, i now understand it better :)