📜  javascript代码示例中的函数声明和函数定义

📅  最后修改于: 2022-03-11 15:02:02.860000             🧑  作者: Mango

代码示例1
//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