函数声明和函数表达式声明的区别

函数声明:

sum(); //10

function sum(){ console.log(10)}

表达式声明

   s(); //报错 s is not a function

   var s = function(){ console.log(20)}

在预解析的过程中,函数会存储整个,因此可以在之前调用,表达式是var声明,只会存储undefined

posted @ 2022-09-26 20:20  九毛九  阅读(28)  评论(0)    收藏  举报