You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/01-getting-started/1-intro/article.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,10 +106,18 @@ Tools modern membuat transpilasi sangat cepat dan transparan, yang memungkinkan
106
106
107
107
Contoh bahasa yang dimaksud:
108
108
109
+
<<<<<<< HEAD
109
110
-[CoffeeScript](http://coffeescript.org/) merupakan "syntactic sugar" dari JavaScript. Dia memperkenalkan syntax yang lebih pendek, memungkingkan kita menulis kode lebih bersih dan lebih presisi. Biasanya, Ruby devs menyukainya.
110
111
-[TypeScript](http://www.typescriptlang.org/) berfokus pada penambahan "strict data typing" yang menyederhanakan pengembangan dan dukungan sistem yang komplex. Ia dikembangkan oleh Microsoft.
111
112
-[Flow](http://flow.org/) juga menambahkan data typing, tapi dalam cara berbeda. Dikembangkan oleh Facebook.
112
113
-[Dart](https://www.dartlang.org/) ialah bahasa mandiri yang punya engine sendiri yang berjalan di lingkungan non-peramban (seperti mobile apps), tapi bisa juga ditranspile ke JavaScript. Dikembangkan oleh Google.
114
+
=======
115
+
-[CoffeeScript](http://coffeescript.org/) is a "syntactic sugar" for JavaScript. It introduces shorter syntax, allowing us to write clearer and more precise code. Usually, Ruby devs like it.
116
+
-[TypeScript](http://www.typescriptlang.org/) is concentrated on adding "strict data typing" to simplify the development and support of complex systems. It is developed by Microsoft.
117
+
-[Flow](http://flow.org/) also adds data typing, but in a different way. Developed by Facebook.
118
+
-[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.
119
+
-[Brython](https://brython.info/) is a Python transpiler to JavaScript that allow to write application in pure Python without JavaScript.
120
+
>>>>>>> f830bc5d9454d85829e011d914f215eb5896579a
113
121
114
122
Masih banyak lagi. Tentunya, jika kita menggunakan salah satu bahasa yang ditranspile tersebut, kita sebaiknya juga paham JavaScript untuk mengerti apa yang mereka lakukan.
Sebenarnya `BigInt` jarang dibutuhkan, kita tidak akan mempelajarinya disini, tetapi akan dipisahkan didalam bagian <info:bigint>. Baca saja saat kamu membutuhkan nilai *integer* yang sangat panjang.
83
83
84
+
<<<<<<<HEAD
84
85
```smart header="Masalah Kompabilitas"
85
86
Sekarang `BigInt` sudah didukung oleh Firefox/Chrome/Edge, tapi tidak didalam Safari/Internet Explorer.
87
+
=======
88
+
```smart header="Compatibility issues"
89
+
Right now `BigInt` is supported in Firefox/Chrome/Edge, but not in Safari/IE.
Copy file name to clipboardExpand all lines: 1-js/05-data-types/04-array/article.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -193,7 +193,11 @@ Sebuah *array* adalah objek yang spesial. Tanda kurung siku digunakan untuk meng
193
193
194
194
Sintaks tersebut memperpanjang objek yang menyediakan metode khusus untuk berfungsi dengan koleksi-koleksi data yang tertata serta properti `length`. Tetapi pada intinya, *array* tetaplah sebuah objek.
195
195
196
+
<<<<<<< HEAD
196
197
Ingat, ada 7 tipe (data) dasar dalamJavaScript. *Array* adalah sebuah objek dan oleh karena itu berperilaku selayaknya sebuah objek.
198
+
=======
199
+
Remember, there are only eight basic data types in JavaScript (see the [Data types](https://javascript.info/types) chapter for more info). Array is an object and thus behaves like an object.
Copy file name to clipboardExpand all lines: 1-js/06-advanced-functions/05-global-object/article.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,11 @@ Objek global menyediakan variabel dan fungsi yang bisa didapatkan dimana saja. S
5
5
6
6
Di dalam browser ia dinamakan `window`, untuk Node.js `global`, untuk lingkungan lainnya ia mungkin mempunyai nama lain.
7
7
8
+
<<<<<<< HEAD
8
9
Akhir-akhir ini, `globalThis` ditambahkan ke bahasanya, sebagai nama standar untuk objek global, yang harus di dukung di semua lingkungan. Di browser tertentu, ya itu non-Chromium Edge, `globalThis` belum didukung, tapi bisa dengan mudah dipolyfill.
10
+
=======
11
+
Recently, `globalThis` was added to the language, as a standardized name for a global object, that should be supported across all environments. It's supported in all major browsers.
12
+
>>>>>>> f830bc5d9454d85829e011d914f215eb5896579a
9
13
10
14
Kita akan memakai `window` disini, dengan anggapan bahwa lingkungan kita adalah browser. Jika script kamu mungkin digunakan di lingkungan lain, lebih baik menggunakan `globalThis`.
11
15
@@ -79,9 +83,16 @@ if (!window.Promise) {
79
83
80
84
- Objek global menyimpan variabel yang harus tersedia dimana saja.
81
85
86
+
<<<<<<< HEAD
82
87
Itu termasuk built-in Javascript, seperti `Array` dan nilai-nilai lingkungan-spesifik, seperti `window.innerHeight` -- tinggi window di dalam browser.
83
88
- Objek global mempunyai nama universal `globalThis`.
84
89
...Tapi lebih sering disebut nama lingkungan-spesifik "old-school", seperti `window` (browser) dan `global` (Node.js). Karena `globalThis` adalah usulan baru, ia belum didukung di dalam non-Chromium Edge (tapi bisa dipolyfill).
85
90
- Kita harus menyimpan nilai di objek global jika kalau ia benar-benar global untuk projek kita. Dan pertahankan jumlah minimum.
86
91
- Dalam browser, jika kita tidak menggunakan [modules](info:modules), fungsi global dan variabel ternyatakan `var` menjadi properti objek global.
87
92
- Untuk membuat kode kami future-proof dan lebih mudah dimengerti, kita harus mengakses properti dari global objek secara langsung, sebagain `window.x`.
93
+
=======
94
+
...But more often is referred by "old-school" environment-specific names, such as `window` (browser) and `global` (Node.js).
95
+
- We should store values in the global object only if they're truly global for our project. And keep their number at minimum.
96
+
- In-browser, unless we're using [modules](info:modules), global functions and variables declared with `var` become a property of the global object.
97
+
- To make our code future-proof and easier to understand, we should access properties of the global object directly, as `window.x`.
Copy file name to clipboardExpand all lines: 1-js/08-prototypes/01-prototype-inheritance/article.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -197,6 +197,9 @@ alert(admin.fullName); // John Smith (*)
197
197
198
198
// setter triggers!
199
199
admin.fullName="Alice Cooper"; // (**)
200
+
201
+
alert(admin.fullName); // Alice Cooper , state of admin modified
202
+
alert(user.fullName); // John Smith , state of user protected
200
203
```
201
204
202
205
Here in the line `(*)` the property `admin.fullName` has a getter in the prototype `user`, so it is called. And in the line `(**)` the property has a setter in the prototype, so it is called.
Copy file name to clipboardExpand all lines: 2-ui/2-events/02-bubbling-and-capturing/article.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -206,7 +206,7 @@ When an event happens -- the most nested element where it happens gets labeled a
206
206
207
207
- Then the event moves down from the document root to `event.target`, calling handlers assigned with `addEventListener(..., true)` on the way (`true` is a shorthand for `{capture: true}`).
208
208
- Then handlers are called on the target element itself.
209
-
- Then the event bubbles up from `event.target` up to the root, calling handlers assigned using `on<event>` and `addEventListener` without the 3rd argument or with the 3rd argument `false/{capture:false}`.
209
+
- Then the event bubbles up from `event.target` to the root, calling handlers assigned using `on<event>` and `addEventListener` without the 3rd argument or with the 3rd argument `false/{capture:false}`.
210
210
211
211
Each handler can access `event` object properties:
212
212
@@ -220,6 +220,6 @@ The capturing phase is used very rarely, usually we handle events on bubbling. A
220
220
221
221
In real world, when an accident happens, local authorities react first. They know best the area where it happened. Then higher-level authorities if needed.
222
222
223
-
The same for event handlers. The code that set the handler on a particular element knows maximum details about the element and what it does. A handler on a particular `<td>` may be suited for that exactly `<td>`, it knows everything about it, so it should get the chance first. Then its immediate parent also knows about the context, but a little bit less, and so on till the very top element that handles general concepts and runs the last.
223
+
The same for event handlers. The code that set the handler on a particular element knows maximum details about the element and what it does. A handler on a particular `<td>` may be suited for that exactly `<td>`, it knows everything about it, so it should get the chance first. Then its immediate parent also knows about the context, but a little bit less, and so on till the very top element that handles general concepts and runs the last one.
224
224
225
225
Bubbling and capturing lay the foundation for "event delegation" -- an extremely powerful event handling pattern that we study in the next chapter.
Copy file name to clipboardExpand all lines: 2-ui/2-events/05-dispatch-events/article.md
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -187,7 +187,6 @@ Any handler can listen for that event with `rabbit.addEventListener('hide',...)`
187
187
<buttononclick="hide()">Hide()</button>
188
188
189
189
<script>
190
-
// hide() will be called automatically in 2 seconds
191
190
functionhide() {
192
191
letevent=newCustomEvent("hide", {
193
192
cancelable:true// without that flag preventDefault doesn't work
@@ -211,13 +210,13 @@ Please note: the event must have the flag `cancelable: true`, otherwise the call
211
210
212
211
## Events-in-events are synchronous
213
212
214
-
Usually events are processed in a queue. That is: if the browser is processing `onclick` and a new event occurs, e.g. mouse moved, then it's handing is queued up, corresponding `mousemove` handlers will be called after `onclick` processing is finished.
213
+
Usually events are processed in a queue. That is: if the browser is processing `onclick` and a new event occurs, e.g. mouse moved, then it's handling is queued up, corresponding `mousemove` handlers will be called after `onclick` processing is finished.
215
214
216
215
The notable exception is when one event is initiated from within another one, e.g. using `dispatchEvent`. Such events are processed immediately: the new event handlers are called, and then the current event handling is resumed.
217
216
218
217
For instance, in the code below the `menu-open` event is triggered during the `onclick`.
219
218
220
-
It's processed immediately, without waiting for `onlick` handler to end:
219
+
It's processed immediately, without waiting for `onclick` handler to end:
221
220
222
221
223
222
```html run autorun
@@ -243,7 +242,7 @@ The output order is: 1 -> nested -> 2.
243
242
244
243
Please note that the nested event `menu-open` is caught on the `document`. The propagation and handling of the nested event is finished before the processing gets back to the outer code (`onclick`).
245
244
246
-
That's not only about `dispatchEvent`, there are other cases. If an event handler calls methods that trigger to other events -- they are too processed synchronously, in a nested fashion.
245
+
That's not only about `dispatchEvent`, there are other cases. If an event handler calls methods that trigger other events -- they too are processed synchronously, in a nested fashion.
247
246
248
247
Let's say we don't like it. We'd want `onclick` to be fully processed first, independently from `menu-open` or any other nested events.
249
248
@@ -283,9 +282,9 @@ Other constructors of native events like `MouseEvent`, `KeyboardEvent` and so on
283
282
284
283
For custom events we should use `CustomEvent` constructor. It has an additional option named `detail`, we should assign the event-specific data to it. Then all handlers can access it as `event.detail`.
285
284
286
-
Despite the technical possibility to generate browser events like `click` or `keydown`, we should use with the great care.
285
+
Despite the technical possibility of generating browser events like `click` or `keydown`, we should use them with great care.
287
286
288
-
We shouldn't generate browser events as it's a hacky way to run handlers. That's a bad architecture most of the time.
287
+
We shouldn't generate browser events as it's a hacky way to run handlers. That's bad architecture most of the time.
0 commit comments