Skip to content

Commit 0e68c45

Browse files
sheiunlenchen1112
authored andcommitted
Polyfills (#47)
* feat: translation of Polyfills * Update article.md * Update 1-js/03-code-quality/06-polyfills/article.md Co-Authored-By: Tom Wu <[email protected]> * Update 1-js/03-code-quality/06-polyfills/article.md Co-Authored-By: Tom Wu <[email protected]> * Update 1-js/03-code-quality/06-polyfills/article.md Co-Authored-By: Len Chen <[email protected]> * Update 1-js/03-code-quality/06-polyfills/article.md Co-Authored-By: Len Chen <[email protected]> * Update 1-js/03-code-quality/06-polyfills/article.md Co-Authored-By: Len Chen <[email protected]> * Update 1-js/03-code-quality/06-polyfills/article.md Co-Authored-By: Len Chen <[email protected]> * Update 1-js/03-code-quality/06-polyfills/article.md Co-Authored-By: Tom Wu <[email protected]> * Update 1-js/03-code-quality/06-polyfills/article.md Co-Authored-By: Tom Wu <[email protected]> * Update 1-js/03-code-quality/06-polyfills/article.md Co-Authored-By: Tom Wu <[email protected]> * Update 1-js/03-code-quality/06-polyfills/article.md Co-Authored-By: Tom Wu <[email protected]> * Update article.md
1 parent 7a92dc3 commit 0e68c45

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed
Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
11

22
# Polyfills
33

4-
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).
4+
JavaScript 語言穩定發展。有關該語言的新提案會定期出現,他們會被分析,而且如果被認為有價值,則會新增到 <https://tc39.github.io/ecma262/> 的列表中,然後進展至 [規格](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
55

6-
Teams behind JavaScript engines have their own ideas about what to implement first. They may decide to implement proposals that are in draft and postpone things that are already in the spec, because they are less interesting or just harder to do.
6+
JavaScript 引擎背後的團隊對於首先實現什麼有自己的想法。他們可能會決定先實做草案中的提案,反而推延規格中已經存在的提案,因為它們不那麼有趣或純粹只是比較難做。
77

8-
So it's quite common for an engine to implement only the part of the standard.
8+
因此,引擎僅實現部分標準是很普遍的。
99

10-
A good page to see the current state of support for language features is <https://kangax.github.io/compat-table/es6/> (it's big, we have a lot to study yet).
10+
<https://kangax.github.io/compat-table/es6/> 是一個很好的頁面,可以看到目前對語言功能的支援狀態(它很多,我們還有很多要研究)。
1111

1212
## Babel
1313

14-
When we use modern features of the language, some engines may fail to support such code. Just as said, not all features are implemented everywhere.
14+
當我們使用語言的現代功能時,某些引擎可能無法支援這類型的程式碼。就像之前說的,並非所有功能都在各處實現。
1515

16-
Here Babel comes to the rescue.
16+
Babel 是一帖良方。
1717

18-
[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.
18+
[Babel](https://babeljs.io) 是一個 [transpiler](https://en.wikipedia.org/wiki/Source-to-source_compiler)。它將現代的 JavaScript 程式碼重寫成符合舊版的標準。
1919

20-
Actually, there are two parts in Babel:
20+
實際上,Babel 有兩個部分:
2121

22-
1. First, the transpiler program, which rewrites the code. The developer runs it on their own computer. It rewrites the code into the older standard. And then the code is delivered to the website for users. Modern project build systems like [webpack](http://webpack.github.io/) provide means to run transpiler automatically on every code change, so that very easy to integrate into development process.
22+
1. 首先,是 transpiler 程序,該程序重寫程式碼。開發人員在自己的電腦上運行它。它將程式碼重寫為較舊的標準。然後將程式碼交付給用戶的網站。諸如 [webpack](http://webpack.github.io/) 之類的現代專案建置系統提供了每次程式碼變更時自動運行 transpiler 的方法,因此極易整合到開發過程。
2323

24-
2. Second, the polyfill.
24+
2. 第二,polyfill
2525

26-
New language features may include new built-in functions and syntax constructs.
27-
The transpiler rewrites the code, transforming syntax constructs into older ones. But as for new built-in functions, we need to implement them. JavaScript is a highly dynamic language, scripts may add/modify any functions, so that they behave according to the modern standard.
26+
新的語言功能可能包括新的內置函數和語法構件。
27+
Transpiler 重寫程式碼,將語法構件轉換為較舊的語法。但是對於新的內置函數,我們需要實現它們。JavaScript 是一種高度動態的語言,腳本可以新增/修改任何函式,以便它們按照現代標準運行。
2828

29-
A script that updates/adds new functions is called "polyfill". It "fills in" the gap and adds missing implementations.
29+
更新/增加 新功能的腳本稱為 "polyfill"。它 "填補" 了差距,並增加了缺少的實作。
3030

31-
Two interesting polyfills are:
32-
- [core js](https://github.com/zloirock/core-js) that supports a lot, allows to include only needed features.
33-
- [polyfill.io](http://polyfill.io) service that provides a script with polyfills, depending on the features and user's browser.
31+
兩個有趣的 polyfill 是:
32+
- [core js](https://github.com/zloirock/core-js) 支援很多功能,允許僅包含所需的功能。
33+
- [polyfill.io](http://polyfill.io) 服務根據功能和使用者的瀏覽器提供帶有 polyfills 的腳本。
3434

35-
So, if we're going to use modern language features, a transpiler and a polyfill are necessary.
36-
37-
## Examples in the tutorial
35+
因此,如果我們要使用現代語言功能,則需要 transpiler 和 polyfill。
3836

37+
## 教程中的範例
3938

4039
````online
41-
Most examples are runnable at-place, like this:
40+
大多數範例都可以在原地運行,如下所示:
4241
4342
```js run
4443
alert('Press the "Play" button in the upper-right corner to run');
4544
```
4645
47-
Examples that use modern JS will work only if your browser supports it.
46+
只有您的瀏覽器支援時,使用現代 JS 的範例才有效。
4847
````
4948

5049
```offline
51-
As you're reading the offline version, in PDF examples are not runnable. In EPUB some of them can run.
50+
在閱讀離線版本時,PDF 中的範例不可運行。在 EPUB 其中有一些可以運行。
5251
```
5352

54-
Google Chrome is usually the most up-to-date with language features, good to run bleeding-edge demos without any transpilers, but other modern browsers also work fine.
53+
Google Chrome 通常有最新的語言功能,可以很好地運行尖端的演示,而無需任何 transpiler,不過其他現代瀏覽器也運作得還可以。

0 commit comments

Comments
 (0)