js.l19 code example

Example: js.l19

---------------------------------
//1.	[ Function Declarations ]
----------------------------------

	function fun_name(params) {      //parameters
   	operation.............
	}

	fun_name(params)   // call the function.
    
------------------------------    
//2.	[ Function Expressions ]
---------------------------------
	
    const func_name = (params) {      //parameters
   	operation.............
	}

	fun_name(params)   // call the function.
    
    
    
------------------------------------------
    
Example.:
----------

//1.
function function_name(params) {
   // any operation you want //
   return value;
}
const set_variable_name = calling function_name(params);
console.log(); |




//2.
const function_name = function(params){
   // any operation you want //
   return value;
}
const set_variable_name = calling function_name(params);
console.log();


----------------------------------------------------------------------------


Difference between [ Function Declarations ] & [ Function Expressions ]:
----------------------------------------------------------------------------


When a JavaScript file (or HTML document with JavaScript in it) is loaded, 
function declarations are hoisted to the top of the code by the browser before
any code is executed.    What does that mean, exactly?    Specifically, all of
the functions written with function declarations are “known” before any code
is run. This allows you to call a function before you declare.   

||   

Function expressions, however, do not hoist. If you try to run a 
function before you’ve expressed it, you’ll get an error.

Tags:

Misc Example