Javascript Function Basics and The argument Variable
In this lesson we'll cover the basics of Javascript function. We'll learn how to define function using the function
keyword followed by a valid identifier (function name) that is followed by parameters and finally a function body!
We'll also cover the local-variable arguments
that's available inside every function. It's an array-like object that contains all the arguments passed to the function.
You can convert this object into an array (so that you can use array methods like forEach on it) easily using:
Array.prototype.slice.call(arguments);
The code above calls Array.prototype.slice()
with this
refering to arguments
inside the method.
Related:
Warning: Invalid argument supplied for foreach() in /var/www/cssdeck.com/app/modules/labs/views/_details.php on line 68