使用'let'的不同形式 [英] Different forms of using 'let'
本文介绍了使用'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
andname
, and assigning the array first toname
and then tolet
. 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屋!
查看全文