EXERCISE TWO: Write & Test Your First Function | Simple JS Project Training Tutorial

Published: 29 November 2016
on channel: Powerslacker
2,302
11

FULL CODE + IMAGES + SLIDES @ http://blog.breakthru.solutions/learn...

PLAYLIST:    • Learn Javascript with a SIMPLE Projec...  

FOLLOW ME ON TWITTER:   / thepowerslacker  

FURTHER READING
Functions: https://developer.mozilla.org/en-US/d...
Math.random: https://developer.mozilla.org/en-US/d...
Math.floor: https://developer.mozilla.org/en-US/d...
Console.log:

FROM THE DOCS:
Generally speaking, a function is a "subprogram" that can be called by code external (or internal in the case of recursion) to the function. Like the program itself, a function is composed of a sequence of statements called the function body. Values can be passed to a function, and the function will return a value.

In JavaScript, functions are first-class objects, because they can have properties and methods just like any other object. What distinguishes them from other objects is that functions can be called. In brief, they are Function objects.

For more examples and explanations, see also the JavaScript guide about functions.

Description
Every function in JavaScript is a Function object. See Function for information on properties and methods of Function objects.

Functions are not the same as procedures. A function always returns a value, whereas a procedure might not.

To return a value other than the default, a function must have a return statement that specifies the value to return. A function without a return statement will return a default value. In the case of a constructor called with the new keyword, the default value is the value of its this parameter. For all other functions, the default return value is undefined.

The parameters of a function call are the function's arguments. Arguments are passed to functions by value. If the function changes the value of an argument, this change is not reflected globally or in the calling function.


Watch video EXERCISE TWO: Write & Test Your First Function | Simple JS Project Training Tutorial online without registration, duration hours minute second in high quality. This video was added by user Powerslacker 29 November 2016, don't forget to share it with your friends and acquaintances, it has been viewed on our site 2,302 once and liked it 11 people.