Built-in Functions

In previous lessons, you have seen quite a few of JavaScript's built-in functions.
The ones you have seen are summarized at the bottom of this example, but there are many more.

The term function comes from mathematics.
Use of functions is very common in mathematics. For example, you might define a mathematical function named f as follows.
   f(x) = x*x*x      (f is just a rule for cubing numbers)
The function doesn't do anything until you call it. You can call on f as many times as you would like, plugging in different values.
   8    ←   f(2)    
   27   ←   f(3)    
   64   ←   f(4)    
A mathematical function is basically a re-usable rule for doing something useful for you.
The value you plug into it is called the argument of the function. The function f takes one argument and cubes it.

Functions in Javascript.
In programming, the concept of a function is similar in that you can call a function any time you need it to do something useful.
For example, you could call a confirm window twice in a row.
  var bool1  =  confirm("Do agree to the above terms of use?");
  var bool2  =  confirm("Would you like to add a further clarification?");
You supply a string argument to the confirm() function and it returns the user's choice.
In programming, a function is said to return a value.
The confirm() function returns a boolean value which the above code stores into variables.

Below is a summary of the JavaScript functions that have been in the examples so far.
They take arguments of various data types, and most of them return a value.

JavaScript built-in functions previous examples have introduced.
   Returns       Function
   number    ←   parseFloat(string)
   number    ←   Math.round(number)
   string    ←   prompt(string)
   boolean   ←   confirm(string)
                  alert(string)
                  document.write(string)
The last two functions above do not return a value.
Such functions are often called void functions, meaning they are devoid of a returned value.