var 存在变量提升。let 只能在块级作用域内访问。const 用来定义常量,必须初始化,不能修改(对象特殊)
1、var【声明变量】
var 没有块的概念,可以跨块访问,无法跨函数访问;
2、let【声明块中的变量】
let 只能在块作用域里访问,不能跨块访问,也不能跨函数访问;
3、const【声明常量、一旦赋值不可更改】
const 只能在块作用域里访问,而且不能修改值