zoukankan      html  css  js  c++  java
  • let和const命令!

    <script>
             //因为a是全局变量,所以i的值会发生改变
            // var a = [];
            // for(var i = 0; i < 10; i++){
            //     a[i]=function(){
            //         console.log(i);
            //     };
            // }
            // a[6]();//10
            //输出仅在快级作用域中的结果
            // var a = [];
            // for(let i = 0; i < 10; i++){
            //     a[i]=function(){
            //         console.log(i);
            //     };
            // }
            // a[6]();//6
            //-------------------------------单独的作用域
            // for(let i = 0 ; i < 3; i++){
            //     let i= 'abc';
            //     console.log(i);  //abc*3
            // }
            //-----------------------结果不一样
            console.log(foo)
            var foo =2;  //var发生了变量提升 所以是undefined
    
            console.log(abc); //let不会发生变量提升 所以会报错
            let abc = 4;
        </script>
    --------------------- 
    作者:兔子零84 
    来源:CSDN 
    原文:https://blog.csdn.net/weixin_43764814/article/details/84332659 
    版权声明:本文为博主原创文章,转载请附上博文链接!
  • 相关阅读:
    List<Map>遍历相加
    jqgrid属性
    idea Could not autowire. No beans of 'xxxx' type found
    【笔记】抓取百度贴吧
    python url中文转码
    python lxml 库
    Python 基础 (笔记)
    HTML 背景
    HTML Iframe
    HTML 响应式 Web 设计
  • 原文地址:https://www.cnblogs.com/tuziling/p/10080740.html
Copyright © 2011-2022 走看看