Conversation
Co-authored-by: maoxiaoke <thebigyellowbee@qq.com> resolve #4
Contributor
|
校对认领 |
Member
Contributor
|
校对认领 @leviding |
Starriers
reviewed
Apr 22, 2018
|
|
||
| ```js run | ||
| let admin, name; // can declare two variables at once | ||
| let admin, name; // 一次定义两个变量。 |
Contributor
There was a problem hiding this comment.
定义 =》 声明
declare 一般翻译为声明,下同
| 4. Show the value of `admin` using `alert` (must output "John"). | ||
| 1. 定义两个变量:`admin` 和 `name`。 | ||
| 2. 将值 `"John"` 赋给 `name`。 | ||
| 3. 从 `name` 变量中拷贝其值给 `admin`。 |
Contributor
There was a problem hiding this comment.
也可以这样翻译 : 将 name 的变量值拷贝给 admin
| ``` | ||
|
|
||
| Again, we could shorten that to `userName` if we know for sure that the user is current. | ||
| 再一次,如果我们的确直到用户就是当前的用户的话,我们可以使用更短的 `userName`。 |
| 再一次,如果我们的确直到用户就是当前的用户的话,我们可以使用更短的 `userName`。 | ||
|
|
||
| Modern editors and autocomplete make long variable names easy to write. Don't save on them. A name with 3 words in it is fine. | ||
| 现代编辑器可自动补全可以让长变量名变得容易书写。不要节省它们。一个名字中包含三个词就挺好的。 |
Contributor
There was a problem hiding this comment.
第一个 可 =》的
不要节省它们 =》 不要浪费这个特性。 感觉更好些。
Author
|
@allenlongbaobao 不要忘了来校对啊 |
Signed-off-by: sqrtthree <imsqrtthree@gmail.com>
leviding
reviewed
Apr 23, 2018
| ``` | ||
|
|
||
| Now we can put some data into it by using the assignment operator `=`: | ||
| 现在,通过赋值操作符 `=` 为变量添加一些数据。 |
| ``` | ||
|
|
||
| ...Or even in the "comma-first" style: | ||
| ...甚至使用 “逗号优先” 的形式: |
| 有一长串的保留字无法用作变量命名,因为它们被语言本身采用了。 | ||
|
|
||
| For example, words `let`, `class`, `return`, `function` are reserved. | ||
| 比如,单词 `let`, `class`, `return`, `function` 被保留。 |
| ``` | ||
|
|
||
| Variables declared using `const` are called "constants". They cannot be changed. An attempt to do it would cause an error: | ||
| 使用 `const` 声明的变量称为 “常量”。它们不能被修改,尝试这样做就会造成错误: |
| `pageLoadTime` 的值在页面加载之前是未知的,所以采用常规命名。但是它仍然是个常量,因为赋值之后不会改变。 | ||
|
|
||
| In other words, capital-named constants are only used as aliases for "hard-coded" values. | ||
| 换句话说,大写命名的常量仅用作 “硬编码” 值的别名。 |
| - `let` -- is a modern variable declaration. The code must be in strict mode to use `let` in Chrome (V8). | ||
| - `var` -- is an old-school variable declaration. Normally we don't use it at all, but we'll cover subtle differences from `let` in the chapter <info:var>, just in case you need them. | ||
| - `const` -- is like `let`, but the value of the variable can't be changed. | ||
| - `let` -- 新时代的变量声明方式。Chrome(V8) 中代码必须开启严格模式以使用 `let` 。 |
| - `let` -- is a modern variable declaration. The code must be in strict mode to use `let` in Chrome (V8). | ||
| - `var` -- is an old-school variable declaration. Normally we don't use it at all, but we'll cover subtle differences from `let` in the chapter <info:var>, just in case you need them. | ||
| - `const` -- is like `let`, but the value of the variable can't be changed. | ||
| - `let` -- 新时代的变量声明方式。Chrome(V8) 中代码必须开启严格模式以使用 `let` 。 |
| - `const` -- is like `let`, but the value of the variable can't be changed. | ||
| - `let` -- 新时代的变量声明方式。Chrome(V8) 中代码必须开启严格模式以使用 `let` 。 | ||
| - `var` -- 旧时代的变量声明方式。一般情况下,我们不会使用它。但是,我们会在 <info:var> 章节介绍 `var` 和 `let` 的微妙差别,以防你需要它们。 | ||
| - `const` -- 类似于`let`, 但是变量的值无法被修改。 |
Signed-off-by: sqrtthree <imsqrtthree@gmail.com>
Author
|
@leviding Sorry, 之前转移文章的时候光顾着对内容,忽略排版了。现在已经调好了。 |
leviding
approved these changes
Apr 23, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Co-authored-by: maoxiaoke thebigyellowbee@qq.com
Cc @maoxiaoke
resolve #4