Skip to content

1-js/03-code-quality/06-polyfills#40

Merged
leviding merged 2 commits intozh-hansfrom
transfer/polyfills
Apr 24, 2018
Merged

1-js/03-code-quality/06-polyfills#40
leviding merged 2 commits intozh-hansfrom
transfer/polyfills

Conversation

@linhe0x0
Copy link
Copy Markdown

resolve #22

resolve #22
@leviding leviding added the WIP Work in process label Apr 12, 2018
@linhe0x0 linhe0x0 removed the WIP Work in process label Apr 12, 2018
@linhe0x0 linhe0x0 changed the title [WIP] 1-js/03-code-quality/06-polyfills 1-js/03-code-quality/06-polyfills Apr 12, 2018
@linhe0x0 linhe0x0 self-assigned this Apr 12, 2018
@allenlongbaobao
Copy link
Copy Markdown
Contributor

校对认领

@leviding
Copy link
Copy Markdown
Member

@allenlongbaobao ok

Copy link
Copy Markdown
Contributor

@allenlongbaobao allenlongbaobao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

校对完毕! @sqrthree @leviding

这就是 Babel 来拯救的东西。

[Babel](https://babeljs.io) is a [transpiler](https://en.wikipedia.org/wiki/Source-to-source_compiler). It rewrites modern JavaScript code into the previous standard.
[Babel](https://babeljs.io) 是一个 [transpiler](https://en.wikipedia.org/wiki/Source-to-source_compiler)。它将新一代的 JavaScript 代码写入前一个标准中。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[它将新一代的 JavaScript 代码写入前一个标准中] => [它将现代的 JavaScript 代码转化为上一代的标准形式]

transpiler 会重写代码,因此现有的语法特性都被覆盖了。但是对于新特性我们需要写一个特殊的脚本来实现它们。JavaScript 是一个高度动态化的语言。脚本可能不仅是添加一些新特性,还会修改一些内置特性,以便它们根据现代标准表现。

There's a term "polyfill" for scripts that "fill in" the gap and add missing implementations.
脚本有一个术语 “polyfill” 表示用来“填补”缺口并添加缺少的实现。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

引号

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[以便它们根据现代标准表现。] => [以便于它们表现得符合现代标准]

If we orient towards modern engines and do not use features except those supported everywhere, then we don't need to use Babel.

## Examples in the tutorial
如果我们朝着现代引擎进发,并且不使用那些除了任何地方都支持的特性之外的特性,那么我们就不需要使用 Babel。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[如果我们朝着现代引擎进发] => [如果我们的目标是现代引擎]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[并且不使用那些除了任何地方都支持的特性之外的特性] => [并且整个项目不使用其他地方不支持的特性]

Examples that use modern JS will work only if your browser supports it.
````
只有你的浏览器支持它才会工作的现代 JS 例子:
```
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

比原文少了一个点

1. 第一,transpiler 程序,就是重写代码的那个。开发者在他自己的电脑上运行它。它将代码重写到旧的标准中。然后将代码交付给用户的网站。诸如 [webpack](http://webpack.github.io/) [brunch](http://brunch.io/) 这样的现代项目构建系统提供了每当代码改变都会自动运行 transpiler 的方法,因此我们这边没有任何的时间损失。

2. Second, the polyfill.
2. 第二,polyfill.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

句号

# Polyfills

The JavaScript language steadily evolves. New proposals to the language appear regularly, they are analyzed and, if considered worthy, are appended to the list at <https://tc39.github.io/ecma262/> and then progress to the [specification](http://www.ecma-international.org/publications/standards/Ecma-262.htm).
JavaScript 语言在稳步发展。对语言的新提议也会定期出现,它们会被分析讨论,如果认为有价值,就会被加入到 <https://tc39.github.io/ecma262/> 的列表中,然后进入 [规范](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[规范]前多了一个空格

@linhe0x0
Copy link
Copy Markdown
Author

@leviding Done.

@leviding leviding merged commit cd27803 into zh-hans Apr 24, 2018
@leviding leviding deleted the transfer/polyfills branch April 24, 2018 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants