<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>js变量提升</title>
</head>
<body>
<script>
var b = 'boy';
console.log(b);
function fighting() {
console.log(a);
// console.log(c);
//js变量提升.html?_ijt=dv477s2hkj0qpqmacchuor122a:14 Uncaught ReferenceError: c is not defined
if (a === 'apple') {
a = 'Alice';
} else {
a = 'Ada';
}
console.log(a);
var a = 'Andy';
midedle();
function midedle() {
console.log(c++);
var c = 100;
console.log(++c);
small();
function small() {
console.log(a);
}
var c = a = 88;
function bottom() {
console.log(this.b);
b = 'baby';
console.log(b);
}
bottom();
}
}
fighting();
console.log(b);
</script>
</body>
</html>
结果:
c的结果: