Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

functions and variables javascript

/*A function is like an operation, you pass two or more values/variables 
into it, it will output a value (if return is used).
Also, you will not have to redeclare the parameters if you used arguments. */

/* A global variable can be accessed anywhere including in curly braces { }.
You do not have to list them as an argument however it is recommended */

/*            | scroll down |
              v             v     */

/* You will opt a global variable into an argument if
you want it to become a different variable in the function */

/*Use*/ let /*and*/ const /*more often because it will not allow you to
declare it again*/

/*Parameters are like the placeholder variables for the variables
outside the function being used as arguments*/

// Local variables(like in functions) take priority over global variables

/*The */return/* operator will output a value such as */ 4, "string", 
true /*etc. this will not be assigned to a variable unless you do assign it
yourself. */

/*If a*/ return /*operator is not used  it will change the global variable 
instead (if there is one).*/

// A good explenation on global and local variables is below
('  https://www.youtube.com/watch?v=iJKkZA215tQ  ')
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #functions #variables #javascript
ADD COMMENT
Topic
Name
7+3 =