javascript “let”变量在编程中的语言意义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33090193/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Linguistic meaning of 'let' variable in programming
提问by ngstschr
So, I'm a javascript programmer and the new version of JavaScript (ES6)has a new keyword for declaring variables: let
, next to the old one var
.
所以,我是一名 javascript 程序员,新版本的JavaScript (ES6)有一个用于声明变量的新关键字:let
, 在旧的旁边var
。
I know the difference between these two, but I was asking myself: what does let
stand for? var
obviously is an abbreviation of "variable", but let
? Is it an abbreviation as well? Where does it come from?
我知道这两者之间的区别,但我问自己:代表什么let
?var
显然是“ variable”的缩写,但是let
?也是缩写吗?它从何而来?
I googled this and to my amazement, I couldn't find an answer. I already knew Swiftalso has a let
keyword (they use it for constants), but apparently some other programming languages use it as well.
我用谷歌搜索了这个,令我惊讶的是,我找不到答案。我已经知道Swift也有一个let
关键字(他们将它用于常量),但显然其他一些编程语言也使用它。
回答by azium
It comes from the English word 'let'.
它来自英文单词“let”。
verb: "let", "letting". 1. to allow or permit:
动词:“让”,“让”。1. 允许或许可:
// Hey computer, can you please
let
// this
night = 'wonderful'
Lisphas the keyword let
and it's been around since 1958, though it may have come from even earlier.