<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
// var 是函数的作用域,而且可以重新赋值
// const 是块级作用域的,不可以重新赋值
// let 块级作用域,可以重新赋值
let count = 10;
let discount = 0.9;
const key = 'a,b,x';
const person = {
name: "zhang",
age : 10
} // 可以改变对象的属性
const Jelly = Object.freeze(person);//不允许改变对象的属性
(function(){
var name = 'jelly';
console.log(name);
})();//立即执行函数Z
{
const name = "jelly";//使其不覆盖 window 下的name
}
for(let i = 0 ; i < 10;i++ ){
console.log(i)
setTimeout(function(){
console.log(`i:${i}`);
},1000)
}
//0
//1
//2
//3
//4
//5
//6
//7
//8
//9
//i:0
//i:1
//i:2
//i:3
//i:4
//i:5
//i:6
//i:7
//i:8
//i:9
for(var i = 0 ; i < 10;i++ ){
console.log(i)
setTimeout(function(){
console.log(`i:${i}`);
},1000)
}
//0
//1
//2
//3
//4
//5
//6
//7
//8
//9
// 10vsr,const,let.html:65 i:10
</script>
</body>
</html>