Skip to content

Commit 1e23b5d

Browse files
committed
merging all conflicts
2 parents 3c4c432 + d78b01e commit 1e23b5d

File tree

256 files changed

+5049
-1419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+5049
-1419
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: iliakan

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ sftp-config.json
2121
Thumbs.db
2222

2323

24+
/svgs

1-js/01-getting-started/1-intro/article.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,44 @@ Trình duyệt đã có sẵn một Javascript engine đôi khi được gọi l
2424

2525
Những engine khác nhau thì sẽ có những "tên mã" khác nhau. Chẳng hạn:
2626

27+
<<<<<<< HEAD
2728
- [V8](https://vi.wikipedia.org/wiki/Chrome_V8) -- trong Chrome và Opera.
2829
- [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) -- trong Firefox.
2930
- ...Có một số tên mã khác như "Chakra" cho IE, "ChakraCore" cho Microsoft Edge, "Nitro" và "SquirrelFish" cho Safari v.v.
3031

3132
Nên ghi nhớ các thuật ngữ trên bởi vì chúng được sử dụng khá nhiều trong các bài viết dành cho nhà phát triển (developer) trên Internet, và cả chúng ta. Ví dụ, nếu "tính năng X được hỗ trợ bởi V8", vậy nó có lẽ sẽ hoạt động trên Chrome và Opera.
33+
=======
34+
- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- in Chrome, Opera and Edge.
35+
- [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) -- in Firefox.
36+
- ...There are other codenames like "Chakra" for IE, "JavaScriptCore", "Nitro" and "SquirrelFish" for Safari, etc.
37+
38+
The terms above are good to remember because they are used in developer articles on the internet. We'll use them too. For instance, if "a feature X is supported by V8", then it probably works in Chrome, Opera and Edge.
39+
>>>>>>> d78b01e9833009fab534462e05c03cffc51bf0e3
3240
3341
```smart header="Engine hoạt động như thế nào?"
3442
3543
Engine khá phức tạp, tuy nhiên có thể hiểu đơn giản như sau:
3644
45+
<<<<<<< HEAD
3746
1. Engine (được nhúng nếu là trình duyệt) đọc ("phân tích cú pháp") tập lệnh.
3847
2. Tiếp theo nó chuyển đổi ("biên dịch") tập lệnh sang mã máy.
3948
3. Và sau đó mã máy chạy, khá nhanh.
49+
=======
50+
1. The engine (embedded if it's a browser) reads ("parses") the script.
51+
2. Then it converts ("compiles") the script to machine code.
52+
3. And then the machine code runs, pretty fast.
53+
>>>>>>> d78b01e9833009fab534462e05c03cffc51bf0e3
4054
4155
Engine áp dụng tối ưu hóa ở mỗi bước của quá trình. Nó thậm chí còn theo dõi tập lệnh đã biên dịch khi nó chạy, phân tích dữ liệu chạy qua nó và tối ưu hóa hơn nữa mã máy dựa trên kiến thức đó.
4256
```
4357

4458
## JavaScript có thể làm gì trong trình duyệt?
4559

60+
<<<<<<< HEAD
4661
Javascript hiện đại là một ngôn ngữ lập trình "an toàn". Nó không cung cấp quyền truy cập cấp thấp vào bộ nhớ hay CPU, bởi vì ban đầu nó được tạo ra cho trình duyệt vốn dĩ không yêu cầu những điều đó.
62+
=======
63+
Modern JavaScript is a "safe" programming language. It does not provide low-level access to memory or the CPU, because it was initially created for browsers which do not require it.
64+
>>>>>>> d78b01e9833009fab534462e05c03cffc51bf0e3
4765
4866
Sức mạnh của Javascript phụ thuộc rất lớn vào môi trường mà nó đang hoạt động. Chẳng hạn, [Node.js](https://vi.wikipedia.org/wiki/Node.js) hỗ trợ các hàm giúp cho Javascript có thể đọc/ghi các tập tin tùy ý, thực hiện các yêu cầu mạng, etc.
4967

@@ -59,14 +77,19 @@ Ví dụ, JavaScript trong trình duyệt có khả năng:
5977

6078
## JavaScript không thể làm gì trong trình duyệt?
6179

80+
<<<<<<< HEAD
6281
Nhiều tính năng của Javascript trong trình duyệt bị giới hạn vì lợi ích an toàn của người dùng. Mục đích là để ngăn chặn những trang web độc hại truy cập thông tin cá nhân hoặc gây hại đến dữ liệu của người dùng.
82+
=======
83+
JavaScript's abilities in the browser are limited to protect the user's safety. The aim is to prevent an evil webpage from accessing private information or harming the user's data.
84+
>>>>>>> d78b01e9833009fab534462e05c03cffc51bf0e3
6385
6486
Một số hạn chế có thể kể là:
6587

6688
- JavaScript trên một trang web không thể đọc/ghi các tệp tùy ý trên đĩa cứng, sao chép chúng hoặc thực thi các chương trình. Nó không có quyền truy cập trực tiếp vào các chức năng của hệ điều hành.
6789

6890
Nhiều trình duyệt hiện đại cho phép làm việc với tập tin, nhưng bị giới hạn và chỉ được truy cập nếu như người dùng thực hiện một hành động nhất định nào đó, ví dụ như "thả" các tập tin vào cửa sổ trình duyệt hoặc chọn chúng qua thẻ `<input>`.
6991

92+
<<<<<<< HEAD
7093
Có nhiều cách để tương tác với camera/microphone và thiết bị khác, nhưng chúng yêu cầu sự cho phép rõ ràng của người dùng. Vì vậy, một trang web hỗ trợ Javascript sẽ không bật lén camera, quan sát và gửi thông tin cho [NSA](https://vi.wikipedia.org/wiki/C%C6%A1_quan_An_ninh_Qu%E1%BB%91c_gia_(Hoa_K%E1%BB%B3)).
7194
- Các tab/cửa sổ nhìn chung không biết gì về nhau. Thỉnh thoảng có, ví dụ như một cửa sổ dùng Javascript để mở cửa sổ khác. Nhưng kể cả như vậy, JavaScript từ trang này vẫn không thể can thiệp vào trang kia nếu như chúng đến từ tên miền, giao thức hoặc port khác.
7295

@@ -78,33 +101,61 @@ Một số hạn chế có thể kể là:
78101
![](limitations.svg)
79102

80103
Những giới hạn trên sẽ không tồn tại nếu như Javascript được sử dụng bên ngoài trình duyệt, như máy chủ chẳng hạn. Các trình duyệt hiện đại cũng cho phép các plugin/tiện ích có thể hỏi cho các quyền mở rộng.
104+
=======
105+
There are ways to interact with the camera/microphone and other devices, but they require a user's explicit permission. So a JavaScript-enabled page may not sneakily enable a web-camera, observe the surroundings and send the information to the [NSA](https://en.wikipedia.org/wiki/National_Security_Agency).
106+
- Different tabs/windows generally do not know about each other. Sometimes they do, for example when one window uses JavaScript to open the other one. But even in this case, JavaScript from one page may not access the other page if they come from different sites (from a different domain, protocol or port).
107+
108+
This is called the "Same Origin Policy". To work around that, *both pages* must agree for data exchange and must contain special JavaScript code that handles it. We'll cover that in the tutorial.
109+
110+
This limitation is, again, for the user's safety. A page from `http://anysite.com` which a user has opened must not be able to access another browser tab with the URL `http://gmail.com`, for example, and steal information from there.
111+
- JavaScript can easily communicate over the net to the server where the current page came from. But its ability to receive data from other sites/domains is crippled. Though possible, it requires explicit agreement (expressed in HTTP headers) from the remote side. Once again, that's a safety limitation.
112+
113+
![](limitations.svg)
114+
115+
Such limitations do not exist if JavaScript is used outside of the browser, for example on a server. Modern browsers also allow plugins/extensions which may ask for extended permissions.
116+
>>>>>>> d78b01e9833009fab534462e05c03cffc51bf0e3
81117
82118
## Điều gì khiến cho Javascript khác biệt?
83119

84120
Có ít nhất *ba* điều tuyệt vời ở Javascript:
85121

86122
```compare
123+
<<<<<<< HEAD
87124
+ Tích hợp hoàn toàn với HTML/CSS.
88125
+ Những điều đơn giản được thực hiện một cách đơn giản.
89126
+ Được hỗ trợ bởi tất cả các trình duyệt chính và được bật theo mặc định.
127+
=======
128+
+ Full integration with HTML/CSS.
129+
+ Simple things are done simply.
130+
+ Supported by all major browsers and enabled by default.
131+
>>>>>>> d78b01e9833009fab534462e05c03cffc51bf0e3
90132
```
91133

92134
Javascript là công nghệ trình duyệt duy nhất kết hợp cả 3 điều trên.
93135

136+
<<<<<<< HEAD
94137
Đó là những thứ khiến cho Javascript trở nên độc đáo. Đó là lí do tại sao nó là công cụ phổ biến nhất để tạo giao diện trình duyệt.
138+
=======
139+
That said, JavaScript can be used to create servers, mobile applications, etc.
140+
>>>>>>> d78b01e9833009fab534462e05c03cffc51bf0e3
95141
96142
Điều đó nói rằng, JavaScript cũng cho phép tạo các ứng dụng di động, máy chủ v.v.
97143

98144
## Những ngôn ngữ "trên nền tảng" JavaScript
99145

100146
Cú pháp của Javascript không phù hợp cho tất cả mọi người. Những người khác nhau lại muốn các tính năng khác nhau.
101147

148+
<<<<<<< HEAD
102149
Đó là điều được mong đợi, vì các dự án và yêu cầu đều khác nhau đối với mọi người.
150+
=======
151+
So, recently a plethora of new languages appeared, which are *transpiled* (converted) to JavaScript before they run in the browser.
152+
>>>>>>> d78b01e9833009fab534462e05c03cffc51bf0e3
103153
104154
Vì vậy gần đây có rất nhiêu ngôn ngữ mới xuất hiện, chúng được *dịch mã* (chuyển đổi) sang Javascript trước khi chúng chạy trên trình duyệt.
105155

106156
Những công cụ hiện đại làm cho việc dịch trở nên nhanh chóng và minh bạch, thực sự cho phép các nhà phát triển viết mã bằng ngôn ngữ khác và tự động chuyển đổi nó trơn tru và hiệu quả.
107157

158+
<<<<<<< HEAD
108159
Có thể kể đến một số ngôn ngữ:
109160

110161
- [CoffeeScript](http://coffeescript.org/) là một "cú pháp đặc biệt" cho JavaScript. Nó giới thiệu cú pháp ngắn hơn, cho phép chúng ta viết mã rõ ràng và chính xác hơn. Thông thường thì các nhà phát triển Ruby thích nó.
@@ -113,11 +164,27 @@ Có thể kể đến một số ngôn ngữ:
113164
- [Dart](https://www.dartlang.org/) là một ngôn ngữ độc lập có engine riêng và có thể chạy trong môi trường khác ngoài trình duyệt, nó cũng có thể được dịch sang Javascript. Phát triển bởi Google.
114165
- [Brython](https://brython.info/) là một trình chuyển tiếp Python sang JavaScript cho phép viết các ứng dụng bằng Python thuần túy mà không cần JavaScript.
115166
- [Kotlin](https://kotlinlang.org/docs/reference/js-overview.html) là một ngôn ngữ lập trình hiện đại, ngắn gọn và an toàn, mà có thể nhắm đến trình duyệt hoặc Node.
167+
=======
168+
- [CoffeeScript](https://coffeescript.org/) is "syntactic sugar" for JavaScript. It introduces shorter syntax, allowing us to write clearer and more precise code. Usually, Ruby devs like it.
169+
- [TypeScript](https://www.typescriptlang.org/) is concentrated on adding "strict data typing" to simplify the development and support of complex systems. It is developed by Microsoft.
170+
- [Flow](https://flow.org/) also adds data typing, but in a different way. Developed by Facebook.
171+
- [Dart](https://www.dartlang.org/) is a standalone language that has its own engine that runs in non-browser environments (like mobile apps), but also can be transpiled to JavaScript. Developed by Google.
172+
- [Brython](https://brython.info/) is a Python transpiler to JavaScript that enables the writing of applications in pure Python without JavaScript.
173+
- [Kotlin](https://kotlinlang.org/docs/reference/js-overview.html) is a modern, concise and safe programming language that can target the browser or Node.
174+
175+
There are more. Of course, even if we use one of these transpiled languages, we should also know JavaScript to really understand what we're doing.
176+
>>>>>>> d78b01e9833009fab534462e05c03cffc51bf0e3
116177
117178
Sẽ có nhiều hơn số kể trên. Dĩ nhiên, ngay cả khi chúng ta sử dụng một trong những ngôn ngữ đó, chúng ta cũng nên biết Javascript để thực sự hiểu chúng ta đang làm gì.
118179

180+
<<<<<<< HEAD
119181
## Tóm tắt
120182

121183
- Javascript được tạo ra với mục đích ban đầu chỉ cho trình duyệt, nhưng bây giờ đã được sử dụng rộng rãi trên nhiều môi trường khác.
122184
- Ngày nay, Javascript có một vị trí khác biệt như là ngôn ngữ trình duyệt được sử dụng rộng rãi nhất với sự tích hợp đầy đủ với HTML/CSS.
123185
- Có nhiều ngôn ngữ được "dịch" sang JavaScript và cung cấp một số tính năng nhất định. Nên xem qua chúng, ít nhất là một thời gian ngắn sau khi thành thạo JavaScript.
186+
=======
187+
- JavaScript was initially created as a browser-only language, but it is now used in many other environments as well.
188+
- Today, JavaScript has a unique position as the most widely-adopted browser language, fully integrated with HTML/CSS.
189+
- There are many languages that get "transpiled" to JavaScript and provide certain features. It is recommended to take a look at them, at least briefly, after mastering JavaScript.
190+
>>>>>>> d78b01e9833009fab534462e05c03cffc51bf0e3

1-js/01-getting-started/2-manuals-specifications/article.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22

33
Cuốn sách này là một *hướng dẫn*. Nó nhằm mục đích giúp bạn dần dần học ngôn ngữ. Nhưng một khi bạn quen với những thứ căn bản, bạn sẽ cần các nguồn khác.
44

5+
<<<<<<< HEAD
56
## Đặc tả
7+
=======
8+
This book is a *tutorial*. It aims to help you gradually learn the language. But once you're familiar with the basics, you'll need other resources.
9+
>>>>>>> d78b01e9833009fab534462e05c03cffc51bf0e3
610
711
[Đặc tả ECMA-262](https://www.ecma-international.org/publications/standards/Ecma-262.htm) chứa thông tin chuyên sâu, chi tiết và chính thức nhất về JavaScript. Nó xác định đặc điểm ngôn ngữ.
812

913
Nhưng với việc được chính thức hóa như vậy, thoạt đầu nó thật khó hiểu. Vì vậy, nếu bạn cần nguồn thông tin đáng tin cậy nhất về chi tiết ngôn ngữ, thì bản đặc tả là nơi phù hợp. Nhưng nó không phải để sử dụng hàng ngày.
1014

1115
Một phiên bản đặc tả mới được phát hành hàng năm. Giữa các bản phát hành này, bản nháp đặc tả mới nhất có tại <https://tc39.es/ecma262/>.
1216

17+
<<<<<<< HEAD
1318
Để đọc về những tính năng mới nhất, bao gồm cả các tính năng gần như tiêu chuẩn (được gọi là "stage-3") xem tại: <https://github.com/tc39/proposals>.
19+
=======
20+
A new specification version is released every year. Between these releases, the latest specification draft is at <https://tc39.es/ecma262/>.
21+
>>>>>>> d78b01e9833009fab534462e05c03cffc51bf0e3
1422
1523
Ngoài ra, nếu bạn đang phát triển cho trình duyệt, thì có các đặc tả khác được đề cập trong [phần thứ hai](info:browser-environment) của hướng dẫn.
1624

@@ -20,18 +28,31 @@ Ngoài ra, nếu bạn đang phát triển cho trình duyệt, thì có các đ
2028

2129
Bạn có thể tìm thấy nó tại <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference>.
2230

31+
<<<<<<< HEAD
2332

2433
Dầu vậy, thông thường tốt nhất là sử dụng tìm kiếm trên Internet. Chỉ cần sử dụng "MDN [term]" trong truy vấn, ví dụ: <https://google.com/search?q=MDN+parseInt> để tìm kiếm hàm `parseInt`.
34+
=======
35+
You can find it at <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference>.
36+
37+
Although, it's often best to use an internet search instead. Just use "MDN [term]" in the query, e.g. <https://google.com/search?q=MDN+parseInt> to search for the `parseInt` function.
38+
>>>>>>> d78b01e9833009fab534462e05c03cffc51bf0e3
2539
2640
## Bảng tương thích
2741

2842
JavaScript là một ngôn ngữ đang phát triển, các tính năng mới được bổ sung thường xuyên.
2943

3044
Để xem sự hỗ trợ chúng giữa các engine dựa trên trình duyệt và các engine khác, hãy xem:
3145

46+
<<<<<<< HEAD
3247
- <http://caniuse.com> - các bảng hỗ trợ theo từng tính năng, ví dụ: để xem engine nào hỗ trợ các hàm mã hóa hiện đại: <http://caniuse.com/#feat=cryptography>.
3348
- <https://kangax.github.io/compat-table> - một bảng với các tính năng và các engine mà có hoặc không hỗ trợ các tính năng đó.
3449

3550
Tất cả các tài nguyên này đều hữu ích cho việc phát triển trong đời thực, vì chúng chứa thông tin có giá trị về các chi tiết ngôn ngữ, sự hỗ trợ chúng v.v.
51+
=======
52+
- <https://caniuse.com> - per-feature tables of support, e.g. to see which engines support modern cryptography functions: <https://caniuse.com/#feat=cryptography>.
53+
- <https://kangax.github.io/compat-table> - a table with language features and engines that support those or don't support.
54+
55+
All these resources are useful in real-life development, as they contain valuable information about language details, their support, etc.
56+
>>>>>>> d78b01e9833009fab534462e05c03cffc51bf0e3
3657
3758
Vui lòng ghi nhớ những tài nguyên trên (hoặc trang này) trong các trường hợp bạn cần thông tin chuyên sâu về một tính năng cụ thể.

1-js/01-getting-started/3-code-editors/article.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ An IDE loads the project (which can be many files), allows navigation between fi
1313
If you haven't selected an IDE yet, consider the following options:
1414

1515
- [Visual Studio Code](https://code.visualstudio.com/) (cross-platform, free).
16-
- [WebStorm](http://www.jetbrains.com/webstorm/) (cross-platform, paid).
16+
- [WebStorm](https://www.jetbrains.com/webstorm/) (cross-platform, paid).
1717

1818
For Windows, there's also "Visual Studio", not to be confused with "Visual Studio Code". "Visual Studio" is a paid and mighty Windows-only editor, well-suited for the .NET platform. It's also good at JavaScript. There's also a free version [Visual Studio Community](https://www.visualstudio.com/vs/community/).
1919

@@ -29,13 +29,11 @@ The main difference between a "lightweight editor" and an "IDE" is that an IDE w
2929

3030
In practice, lightweight editors may have a lot of plugins including directory-level syntax analyzers and autocompleters, so there's no strict border between a lightweight editor and an IDE.
3131

32-
The following options deserve your attention:
32+
There are many options, for instance:
3333

34-
- [Atom](https://atom.io/) (cross-platform, free).
35-
- [Visual Studio Code](https://code.visualstudio.com/) (cross-platform, free).
36-
- [Sublime Text](http://www.sublimetext.com) (cross-platform, shareware).
34+
- [Sublime Text](https://www.sublimetext.com/) (cross-platform, shareware).
3735
- [Notepad++](https://notepad-plus-plus.org/) (Windows, free).
38-
- [Vim](http://www.vim.org/) and [Emacs](https://www.gnu.org/software/emacs/) are also cool if you know how to use them.
36+
- [Vim](https://www.vim.org/) and [Emacs](https://www.gnu.org/software/emacs/) are also cool if you know how to use them.
3937

4038
## Let's not argue
4139

@@ -44,3 +42,8 @@ The editors in the lists above are those that either I or my friends whom I cons
4442
There are other great editors in our big world. Please choose the one you like the most.
4543

4644
The choice of an editor, like any other tool, is individual and depends on your projects, habits, and personal preferences.
45+
46+
The author's personal opinion:
47+
48+
- I'd use [Visual Studio Code](https://code.visualstudio.com/) if I develop mostly frontend.
49+
- Otherwise, if it's mostly another language/platform and partially frontend, then consider other editors, such as XCode (Mac), Visual Studio (Windows) or Jetbrains family (Webstorm, PHPStorm, RubyMine etc, depending on the language).

0 commit comments

Comments
 (0)