<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body></body>
<script>
//let不能重复定义
var a;
//let b;
let a;
let b, c, d;
let e = 100;
let f = 521,
g = "crow",
h = [];
//let有区块作用域
{
let star = 5;
}
console.log(star); //not defined
{
var star1 = 6;
}
console.log(star1);
//let不会提升作用域,var会
console.log(song);
let song = "12323";
{
var star1 = 7;
}
console.log(star1);
//v全局var会挂载到window对象上,let不会
var date_1 = 123;
console.log(window.date_1); //123
function bbbb() {
console.log("ppppp"); //pppp
}
console.log(window.bbbb()); //undefined
let date_2 = 321;
console.log(window.date_2); //undefined
</script>
</html>
09 es6 let常量
最新推荐文章于 2024-08-14 10:08:54 发布