day1:今天梳理一个小知识点-javascript的变量提升
例子1 变量提升
console.log(b) // undefined var b = 3 ````````````````// 下面是运行时 var b console.log(b) b = 3例子中var声明的变量b自身会被提升到作用域的最前面
·························································我是手敲的分割线·······························································
例子2 函数提升-具名函数(函数声明式)
a() function a() { console.log(1) } ``````````````// 下面是运行时 function a() { console.log(1) } a()例子中函数a在声明的时候 自身及声明的内容 会被提升到作用域的最前面
·························································我是手敲的分割线·······························································
例子3 具名函数(函数字面量式)
c() var c = function () { console.log(1) } ``````````````// 下面是运行时 var c c() // c is not a function c = function() { console.log(1) } c()例子中var声明的变量c 自身 会被提升到作用域的最前面,该例子和例子1同理