Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

function declaration and function definition in javascript

//Function declarations load 
//before any code is executed
//while 
//Function expressions load
//only when the interpreter reaches that line of code.
//eg. 
add(1,2); 
function add(a,b){	//this is a function declaration 
  return a+b;
}
sum(1,5); //this is a function expression will throw initialization error
const sum = () => a+b; //function expression is strored in variable
 
PREVIOUS NEXT
Tagged: #function #declaration #function #definition #javascript
ADD COMMENT
Topic
Name
4+3 =