this/window

Typing this into the console in a browser will return the window object. This contains all of the default functions and objects that are available in the browser window, as well as the user generated functions and objects included in the .html file that was loaded.

One interesting thing within the window is MMath, where there is a .random function within it. Calling Math.random will return a randomised number.

Another useful function is Error. This can be used within something like an if statement:

if(circle.radius !== 10){
throw new Error("The circle radius is not 10.")
}

results matching ""

    No results matching ""