FAQ: Introduction to JavaScript - Built-in Objects

Math is a built-in object that works with the Number type. Like all the built-ins, it is capitalized. console has no bindings to the global object. We can only access it through the browser Developer Tools menu.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects

https://developer.mozilla.org/en-US/docs/Web/API/console

There may be some ambiguity, here, owing that I’ve never been down the Window.console road. Window.console property returns a reference to the Console object. What this means for us is still in question.

https://developer.mozilla.org/en-US/docs/Web/API/Window/console

1 Like

Why are these objects case sensitive to inputs
eg

console.log(Math.random()); - gives correct results
but
if console.log(math.Random()); —gives error----why

Insights plzz

The Math object is a global object that is available in javascript. Just like any other object it is saved in a variable. The variable is Math. Just as when you assign a variable name it is case sensitive. The methods assigned are also case sensitive.

JavaScript is case sensitive.

math

and,

Math

are worlds apart.

As the course progresses we learn how to create custom objects called Classes. The convention in JS is to capitalize class names, which is why Math is capitalized. It is a class. The Math class. The only difference between it and the classes we will build is that it is not a constructor and has only static methods. We learn all about this later on.

We can find all the properties of the class in the documentation.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math

The exercise says that console is an object built into JavaScript, but console is not on the list of objects on the page they link to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects

Why?

console is not a global object but it can be accessed from any global object.

The Window.console property returns a reference to the Console object, which provides methods for logging information to the browser’s console. These methods are intended for debugging purposes only and should not be relied on for presenting information to end users

As to ‘why?’ the operative phrase above is, ‘intended for debugging’.

This may seem like a stupid question but how do we find out what methods are contained in an object without using the internet (as you may not always have access to it but can still write code)? Ive done the basic c++ course codecademy and I always meant to ask how you know what is contained in a specific library without using the internet?
Andy

1 Like

4 posts were split to a new topic: Does that mean it’s never going to be 1?

are objects and libraries the same thing? Their definitions in this module are the same.

Libraries are also objects, which is what pretty much everything is in JS. It goes a little deeper, though. Modules are object literals, and some libraries, such as lodash.js are also object literals, but many are function objects, such as jQuery.js.

1 Like

I realized this too. With exactly that section. I think what this whole course does is let you pass to the next section after getting it wrong twice… i think… because my second attempt to that was accepted as correct and it was slightly different from what you got… yet… when i restarted the section and just let the hints guide me, i saw that the correct answer is something different ENTIRELY. The hint told me to look for “Math.ceil(0)” which is defined as “Returns the smallest integer greater than or equal to x”.

Now, because they are fundamentally different from the combination of math floor and math random it took me 30 minutes to even realize that i was supposed to use something else. sigh This has happened on literally ALL coding tutorials. It’s like ALL CODING TUTORIALS don’t understand that because this is not math, that we can’t just assume things because we are literally learning new logic (because we are learning what different Methods are and what they do) so we need to be told EXACTLY when we are going to switch to a new method because most of us are still just following instructions and have NO INTUITION for this yet. At least I don’t, and I am the target audience for this because i have 0 coding knowledge.

This is super frustrating especially seeing that i guess this is a flaw that ALL CODERS and CODING… INSTITUTIONS(?) have that they don’t know how to teach people that truly don’t know anything about code.