使用'let'的不同形式 [英] Different forms of using 'let'

查看:72
本文介绍了使用'let'的不同形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了一个JavaScript ES6的教程,其中的人使用这种语法来赋值

I saw a tutorial for JavaScript ES6 in which the guy used this syntax to assign a value with let:

let = name = ['Jhon','Paul','Ean']

第一个和第一个之间有什么区别:

What is the difference between the first and this:

let name = ['Jhon','Paul','Ean']


推荐答案


  • 第一个是创建两个全局变量: let name
    首先将数组分配给 name ,然后分配给。它不是你想要的

    • The first one is creating two global variables: let and name, and assigning the array first to name and then to let. It is not what you want for sure.

      第二个创建一个名为 name的块范围局部变量。这个
      就是你想要的!

      The second one creates a block scope local variable called name. This is one what you want!

      这篇关于使用'let'的不同形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆