let const关键字

let 是取代var

在块级作用域里面有效

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script type="application/javascript">
        {
            var a=1;
            let b=2;

        }
        console.log(a);
    console.log(b);
    </script>
</body>
</html>

 

 

cons定义常量

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script type="application/javascript">
           const a=12;
           a=6;
           console.log(a);
    </script>
</body>
</html>

  

 

posted on 2019-06-30 11:11  nidegui  阅读(145)  评论(0编辑  收藏  举报