body ack 实现 con es6 没有 func script hang
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- <script>
- // 在ES5中,只有全局作用域和函数作用域,并没有块作用域,当然我们可以实现块作用域的功能。
- //在ES6中,let为js添加了新的作用域就是块作用域
- function person(){
- if(true){
- var name = ‘zhangsan‘
- }
- }
- console.log(name)
- if(true){
- var age =12;
- }
- console.log(age)// 12
- if(true){
- let ages =20;
- }
- console.log(ages)// undefined
- </script>
- </body>
- </html>
详解请移步:http://blog.csdn.net/qq_23980427/article/details/54645701
初步理解js作用域
body ack 实现 con es6 没有 func script hang
原文:http://www.cnblogs.com/xiaomili/p/7845727.html
来源: http://www.bubuko.com/infodetail-2397341.html