3. Functions
An introduction to using functions with JavaScript.
Modular Code Using JavaScript Functions
Reuse your existing JavaScript code in multiple places by converting it into functions.
Reuse your existing JavaScript code in multiple places by converting it into functions.
Introduction to Functions
The simplest way to set up reusable code in JavaScript is using Functions.
The simplest way to set up reusable code in JavaScript is using Functions.
How to Call a Function
The way you call a function is slightly different from the way you reference variables.
The way you call a function is slightly different from the way you reference variables.
Same Function Different Variables
If you define arguments for your function then you cal pass different variables as parameters for each call.
If you define arguments for your function then you cal pass different variables as parameters for each call.
Optional Parameters
JavaScript allows you to pass different numbers of parameters to your function at different times.
JavaScript allows you to pass different numbers of parameters to your function at different times.
The Scope of Variables
Variables inside a function may not exist outside of it.
Variables inside a function may not exist outside of it.
Returning a Value
Functions can have a value that they return back into the code they were called from.
Functions can have a value that they return back into the code they were called from.
Function Libraries
Writing your own library of functions or using such a library written by others will make writing JavaScripts faster.
Writing your own library of functions or using such a library written by others will make writing JavaScripts faster.
