Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
f723253
transpiler def
joaquinelio Mar 28, 2021
3d88d33
Update article.md
ZYinMD Jun 13, 2021
2dce19e
"inserts into" instead of "appends to"
joaquinelio Jun 16, 2021
497ca99
Update article.md
joaquinelio Jun 16, 2021
9680c67
Merge pull request #2633 from joaquinelio/patch-4
iliakan Jun 16, 2021
cd466c5
Unnecessary escape characters in cookie.js
NNboru Jun 17, 2021
8c910b4
Update article.md
joaquinelio Jun 18, 2021
8cf2d51
Update article.md
joaquinelio Jun 18, 2021
0c41930
Update article.md
joaquinelio Jun 18, 2021
263f57e
Update article.md
joaquinelio Jun 18, 2021
492f506
Merge pull request #2555 from joaquinelio/patch-6
iliakan Jun 18, 2021
a6dfbb7
minor fixes
iliakan Jun 18, 2021
29f0121
Merge pull request #2636 from NNboru/patch-1
iliakan Jun 18, 2021
de36d0d
update one code comment in 1-js/09-classes/04-private-protected-prope…
ZYinMD Jun 18, 2021
c45e78f
Maybe. "accessors" link
joaquinelio Jun 18, 2021
d43bdd2
slightly improve clarity on Promise.all()
ZYinMD Jun 19, 2021
e49bc3b
Merge pull request #2627 from ZYinMD/patch-5
iliakan Jun 19, 2021
e877796
closes #2641
iliakan Jun 19, 2021
ff53f06
minor fixes
iliakan Jun 19, 2021
cf82cc3
minor fixes
iliakan Jun 19, 2021
85282ef
minor fixes
iliakan Jun 19, 2021
a40ca9a
minor fixes
iliakan Jun 19, 2021
54347b7
minor fixes
iliakan Jun 19, 2021
df6e5a4
minor fixes
iliakan Jun 19, 2021
e769408
minor fixes
iliakan Jun 19, 2021
de81cb4
minor fixes
iliakan Jun 19, 2021
7dacfd4
minor fixes
iliakan Jun 19, 2021
3661393
minor fixes
iliakan Jun 19, 2021
1b16f9d
Merge pull request #2640 from ZYinMD/patch-17
iliakan Jun 19, 2021
6f14c39
Merge pull request #2639 from joaquinelio/patch-4
iliakan Jun 19, 2021
52eaa63
typo
joaquinelio Jun 20, 2021
9847492
Typo in Ch 15 Functions
Yoona8 Jun 20, 2021
140c75d
Merge pull request #2644 from Yoona8/master
iliakan Jun 20, 2021
ffe91a6
Merge pull request #2643 from joaquinelio/patch-6
iliakan Jun 20, 2021
8558fa8
Merge pull request #2638 from ZYinMD/patch-16
iliakan Jun 20, 2021
b19a6f0
minor fixes
iliakan Jun 21, 2021
66bad3f
fix typo in 5-network/02-formdata
ZYinMD Jun 22, 2021
d7c2f08
Add one letter in 5-network/03-fetch-progress
ZYinMD Jun 22, 2021
c4efc35
minor grammar change in webcomponents-intro
ZYinMD Jun 23, 2021
b855f6c
add a section about css animation performance
ZYinMD Jun 24, 2021
9b99012
Merge pull request #2654 from ZYinMD/patch-24
iliakan Jun 24, 2021
c41361f
animation
iliakan Jun 24, 2021
8b3730b
minor fixes
iliakan Jun 24, 2021
2961588
minor fixes
iliakan Jun 24, 2021
753182b
minor fixes
iliakan Jun 24, 2021
7d838b3
minor fixes
iliakan Jun 24, 2021
32f01fb
minor fixes
iliakan Jun 24, 2021
6c15ba4
minor fixes
iliakan Jun 24, 2021
771aab4
minor fixes
iliakan Jun 24, 2021
2eb4251
minor fixes
iliakan Jun 24, 2021
2811211
minor fixes
iliakan Jun 24, 2021
27af482
minor fixes
iliakan Jun 24, 2021
934d32b
minor fixes
iliakan Jun 24, 2021
4420427
minor fixes
iliakan Jun 24, 2021
e609815
minor fixes
iliakan Jun 24, 2021
e06bc63
minor fixes
iliakan Jun 24, 2021
e79ce9d
minor fixes
iliakan Jun 25, 2021
c001068
minor fixes
iliakan Jun 25, 2021
dab34f7
minor fixes
iliakan Jun 26, 2021
e9d2a31
minor fixes
iliakan Jun 26, 2021
a0af69e
minor fixes
iliakan Jun 26, 2021
4ed51aa
minor fixes
iliakan Jun 26, 2021
54688eb
minor fixes
iliakan Jun 26, 2021
6dda47f
minor fixes
iliakan Jun 26, 2021
e8d7f37
minor fixes
iliakan Jun 26, 2021
9bba570
minor fixes
iliakan Jun 26, 2021
7725acc
minor fixes
iliakan Jun 26, 2021
bed62e1
Add generator.return
Manik2375 Jun 27, 2021
624b48b
Update article.md
Manik2375 Jun 27, 2021
8db6519
minor fixes
iliakan Jun 27, 2021
8752573
minor fixes
iliakan Jun 27, 2021
76656bd
minor fixes
iliakan Jun 27, 2021
16b9bda
minor fixes
iliakan Jun 28, 2021
2275894
Merge pull request #2657 from Manik2375/generator.return
iliakan Jul 1, 2021
e195256
Response header name is changed to the right one
websavva Jul 3, 2021
16de27d
Fix a small grammar mistake
iliyu Jul 4, 2021
89e22f8
confusing line
joaquinelio Jul 13, 2021
02c75d2
Update task.md
joaquinelio Jul 13, 2021
19ec58b
Update article.md
Gammadon Jul 16, 2021
ce38273
add a missing colon
mahdyar Jul 17, 2021
c3214e7
Update article.md
iliakan Jul 21, 2021
1bf6973
Merge pull request #2673 from mahdyar/patch-1
iliakan Jul 22, 2021
667eb56
Merge pull request #2672 from Gammadon/patch-1
iliakan Jul 22, 2021
a5f339e
Merge pull request #2670 from joaquinelio/patch-6
iliakan Jul 22, 2021
237d883
Merge pull request #2662 from riri-yu/patch-1
iliakan Jul 22, 2021
cb97b72
Merge pull request #2661 from WebSavva/patch-1
iliakan Jul 22, 2021
df215cd
Merge pull request #2653 from ZYinMD/patch-21
iliakan Jul 22, 2021
614c85a
minor fixes
iliakan Jul 22, 2021
0082fbe
minor fixes
iliakan Jul 22, 2021
173ce27
Merge pull request #2649 from ZYinMD/patch-20
iliakan Jul 22, 2021
823eea4
Merge pull request #2648 from ZYinMD/patch-19
iliakan Jul 22, 2021
2957e71
minor fixes
iliakan Jul 23, 2021
1b1a2c4
minor fixes
iliakan Jul 23, 2021
9c5388c
pointer events improvements
iliakan Jul 24, 2021
57ff060
minor fixes
iliakan Jul 24, 2021
2a6fd54
old and new
joaquinelio Jul 26, 2021
ef8d576
Merge pull request #2680 from joaquinelio/patch-4
iliakan Jul 26, 2021
1808fe3
slider not working on movile
joaquinelio Aug 8, 2021
4a7fe13
Update index.html
joaquinelio Aug 8, 2021
58f9c8d
minor fixes
iliakan Aug 8, 2021
bc08fd1
Merge pull request #2689 from joaquinelio/patch-8
iliakan Aug 8, 2021
d9f110b
merging all conflicts
iliakan Aug 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions 1-js/02-first-steps/04-variables/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ Kini, kita bisa menaruh beberapa data ke dalamnya dengan menggunakan operator pe
let message;

*!*
<<<<<<< HEAD
message = 'Hello'; // simpan string
=======
message = 'Hello'; // store the string 'Hello' in the variable named message
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b
*/!*
```

Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/13-while-for/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ label: {
}
```

...Although, 99.9% of the time `break` used is inside loops, as we've seen in the examples above.
...Although, 99.9% of the time `break` is used inside loops, as we've seen in the examples above.

A `continue` is only possible from inside a loop.
>>>>>>> 6ab384f2512902d74e4b0ff5a6be60e48ab52e96
Expand Down
6 changes: 5 additions & 1 deletion 1-js/02-first-steps/15-function-basics/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ In other words, to put these terms straight:

We declare functions listing their parameters, then call them passing arguments.

In the example above, one might say: "the function `sayMessage` is declared with two parameters, then called with two arguments: `from` and `"Hello"`".
In the example above, one might say: "the function `showMessage` is declared with two parameters, then called with two arguments: `from` and `"Hello"`".


## Default values
Expand Down Expand Up @@ -288,13 +288,17 @@ function showMessage(text) {
showMessage(); // empty message
```

<<<<<<< HEAD
<<<<<<< HEAD
...Atau kita bisa menggunakan operator `||`:

```js
// jika teks parameter tidak ada atau "", set variabel ke 'empty'
=======
...Or we could use the `??` operator:
=======
...Or we could use the `||` operator:
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b

```js
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
Expand Down
4 changes: 4 additions & 0 deletions 1-js/03-code-quality/06-polyfills/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ di chapter ini, tujuan kita adalah untuk mendapatkan intisari cara kerjanya, dan

## Transpilers

<<<<<<< HEAD
Sebuah [transpiler](https://en.wikipedia.org/wiki/Source-to-source_compiler) adalah perangkat lunak khusus yang dapat mengurai ("membaca dan memahami") kode modern, dan menulis ulang menggunakan konstruksi sintaks yang lebih lama, sehingga hasilnya akan sama.
=======
A [transpiler](https://en.wikipedia.org/wiki/Source-to-source_compiler) is a special piece of software that translates source code to another source code. It can parse ("read and understand") modern code and rewrite it using older syntax constructs, so that it'll also work in outdated engines.
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b

Misalnya. JavaScript sebelum tahun 2020 tidak memiliki "nullish coalescing operator" `??`. Jadi, jika pengunjung menggunakan browser yang sudah ketinggalan zaman, ia mungkin gagal memahami kode seperti `height = height ?? 100`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ importance: 2

# Dua fungsi – satu objek

<<<<<<< HEAD
Apakah mungkin untuk membuat fungsi `A` dan fungsi `B` seperti `new A()==new B()`?
=======
Is it possible to create functions `A` and `B` so that `new A() == new B()`?
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b

```js no-beautify
function A() { ... }
Expand Down
7 changes: 5 additions & 2 deletions 1-js/04-object-basics/09-object-toprimitive/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ In case of such operations, objects are auto-converted to primitives, and then t

That's an important limitation, as the result of `obj1 + obj2` can't be another object!

E.g. we can't make objects representing vectors or matrices (or archievements or whatever), add them and expect a "summed" object as the result. Such architectural feats are automatically "off the board".
E.g. we can't make objects representing vectors or matrices (or achievements or whatever), add them and expect a "summed" object as the result. Such architectural feats are automatically "off the board".

So, because we can't do much here, there's no maths with objects in real projects. When it happens, it's usually because of a coding mistake.

Expand Down Expand Up @@ -162,7 +162,7 @@ Jika tidak ada `Symbol.toPrimitive` maka JavaScript mencoba untuk menemukan meto
=======
If there's no `Symbol.toPrimitive` then JavaScript tries to find methods `toString` and `valueOf`:

- For the "string" hint: `toString`, and if it doesn't exist, then `valueOf` (so `toString` has the priority for stirng conversions).
- For the "string" hint: `toString`, and if it doesn't exist, then `valueOf` (so `toString` has the priority for string conversions).
- For other hints: `valueOf`, and if it doesn't exist, then `toString` (so `valueOf` has the priority for maths).

Methods `toString` and `valueOf` come from ancient times. They are not symbols (symbols did not exist that long ago), but rather "regular" string-named methods. They provide an alternative "old-style" way to implement the conversion.
Expand Down Expand Up @@ -318,4 +318,7 @@ Dalam latihan, cukup sering untuk mengimplementasikan `obj.toString()` saja seba
In practice, it's often enough to implement only `obj.toString()` as a "catch-all" method for string conversions that should return a "human-readable" representation of an object, for logging or debugging purposes.

As for math operations, JavaScript doesn't provide a way to "override" them using methods, so real life projects rarely use them on objects.
<<<<<<< HEAD
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
=======
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b
17 changes: 15 additions & 2 deletions 1-js/05-data-types/02-number/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ alert( 7.3e9 ); // 7.3 milyar (7,300,000,000)
Dengan kata lain, `"e"` kalikan angkanya dengan `1` dengan jumlah nol yang diberikan.

```js
1e3 = 1 * 1000 // e3 means *1000
1.23e6 = 1.23 * 1000000 // e6 means *1000000
1e3 === 1 * 1000; // e3 means *1000
1.23e6 === 1.23 * 1000000; // e6 means *1000000
```

Sekarang ayo tulis sesuatu lebih kecil. Katakan, 1 microsecond (sepersejuta second):
Expand All @@ -58,11 +58,19 @@ Jika kita hitung nol di `0.000001`, ada 6 dari mereka. Jadi alaminya `1e-6`.
Dengan kata lain, angka negatif setelah `"e"` artinya pembagian 1 dengan jumlah nol yang diberikan:

```js
<<<<<<< HEAD
// -3 membagi 1 dengan 3 nol
1e-3 = 1 / 1000 (=0.001)

// -6 membagi 1 dengan 6 nol
1.23e-6 = 1.23 / 1000000 (=0.00000123)
=======
// -3 divides by 1 with 3 zeroes
1e-3 === 1 / 1000; // 0.001

// -6 divides by 1 with 6 zeroes
1.23e-6 === 1.23 / 1000000; // 0.00000123
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b
```

### Hex, angka binary dan octal
Expand Down Expand Up @@ -117,7 +125,12 @@ Tolong ingat bahwa dua dot di `123456..toString(36)` bukan typo. Jika kita mau m

Jika kita menaruh dot tunggal: `123456.toString(36)`, maka akan ada galat, karena syntax JavaScript berimplikasi bahwa bagian desimal setelah dot pertama. Dan jika kita menaruh satu dot lagi, maka JavaScript tahu bahwa bagian desimal kosong dan sekarang pergi ke metode.

<<<<<<< HEAD
Juga bisa menulis `(123456).toString(36)`.
=======
Also could write `(123456).toString(36)`.

>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b
```

## Pembulatan
Expand Down
4 changes: 4 additions & 0 deletions 1-js/05-data-types/05-array-methods/12-reduce-object/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ nilai penting: 4

# Buatlah objek dengan kunci dari array

<<<<<<< HEAD
Anggaplah kita menerima sebuah array dari user didalam form `{id:..., name:..., age... }`.
=======
Let's say we received an array of users in the form `{id:..., name:..., age:... }`.
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b

Buatlah sebuah fungsi `groupById(arr)` yang membuat sebuah objek, dengan `id` sebagai key/kunci, dan item array sebagai nilai

Expand Down
18 changes: 17 additions & 1 deletion 1-js/05-data-types/09-keys-values-entries/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,15 @@ Jika kita ingin mengapplikasikan method-method tersebut, kita bisa menggunakan `
If we'd like to apply them, then we can use `Object.entries` followed by `Object.fromEntries`:
>>>>>>> fbf443e414097e5a3a41dd1273ef9a4a3230e72c

<<<<<<< HEAD
1. Gunakan `Object.entries(obj)` untuk mendapatkan array pasangan kunci/nilai dari `obj`.
2. Gunakan method array di array tersebut, contoh `map`.
3. Gunakan `Object.fromEntries(array)` di array hasil untuk mengubahnya kembali menjadi objek.
=======
1. Use `Object.entries(obj)` to get an array of key/value pairs from `obj`.
2. Use array methods on that array, e.g. `map`, to transform these key/value pairs.
3. Use `Object.fromEntries(array)` on the resulting array to turn it back into an object.
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b

Sebagai contoh, kita mempunyai objek dengan harga-harga, dan mau melipat duakan harga-harganya:

Expand All @@ -95,16 +101,26 @@ let prices = {

*!*
let doublePrices = Object.fromEntries(
<<<<<<< HEAD
// ubah menjadi array, map, lalu fromEntries mengembalikan objeknya
Object.entries(prices).map(([key, value]) => [key, value * 2])
=======
// convert prices to array, map each key/value pair into another pair
// and then fromEntries gives back the object
Object.entries(prices).map(entry => [entry[0], entry[1] * 2])
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b
);
*/!*

alert(doublePrices.meat); // 8
```
```

<<<<<<< HEAD
<<<<<<< HEAD
Mungkin ini terlihat susah pertama kalinya, tetapi ini akan menjadi mudah untuk di mengerti setelah kamu menggunakannya beberapa kali. Kita bisa membuat perantaian hebat dengan cara ini.
=======
It may look difficult at first sight, but becomes easy to understand after you use it once or twice. We can make powerful chains of transforms this way.
>>>>>>> 6ab384f2512902d74e4b0ff5a6be60e48ab52e96
=======
It may look difficult at first sight, but becomes easy to understand after you use it once or twice. We can make powerful chains of transforms this way.
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b
31 changes: 28 additions & 3 deletions 1-js/07-object-properties/01-property-descriptors/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ alert(Object.keys(user)); // name

Flag non-configurable (`configurable:false`) terkadang sudah diatur sebelumnya untuk objek dan properti bawaan.

<<<<<<< HEAD
Sebuah properti non-configurable tidak bisa di hapus.
=======
A non-configurable property can't be deleted, its attributes can't be modified.
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b

Sebagai contoh, `Math.PI` adalah non-writable, non-enumerable and non-configurable:

Expand All @@ -216,12 +220,13 @@ alert( JSON.stringify(descriptor, null, 2 ) );
Jadi, seorang programer tidak akan bisa mengganti nilai dari sebuah `Math.PI` atau juga menimpanya.

```js run
Math.PI = 3; // Error
Math.PI = 3; // Error, because it has writable: false

// menghapus Math.PI juga tidak akan bekerja
```
Membuat sebuah properti non-configurable adalah jalan satu arah. kita tidak bisa mengubahnya kembali dengan `defineProperty`.

<<<<<<< HEAD
Tepatnya, non-configurable memberlakukan beberapa pembatasan pada `defineProperty`:
1. tidak bisa mengubah flag `configurable` .
2. tidak bisa mengubah flag `enumerable` .
Expand All @@ -236,8 +241,20 @@ To be precise, non-configurability imposes several restrictions on `defineProper
2. Can't change `enumerable` flag.
3. Can't change `writable: false` to `true` (the other way round works).
4. Can't change `get/set` for an accessor property (but can assign them if absent).
=======
We also can't change `Math.PI` to be `writable` again:

```js run
// Error, because of configurable: false
Object.defineProperty(Math, "PI", { writable: true });
```

**The idea of "configurable: false" is to prevent changes of property flags and its deletion, while allowing to change its value.**
There's absolutely nothing we can do with `Math.PI`.
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b

Making a property non-configurable is a one-way road. We cannot change it back with `defineProperty`.

**Please note: `configurable: false` prevents changes of property flags and its deletion, while allowing to change its value.**

Here `user.name` is non-configurable, but we can still change it (as it's writable):
>>>>>>> e074a5f825a3d10b0c1e5e82561162f75516d7e3
Expand All @@ -255,7 +272,7 @@ user.name = "Pete"; // works fine
delete user.name; // Error
```

And here we make `user.name` a "forever sealed" constant:
And here we make `user.name` a "forever sealed" constant, just like the built-in `Math.PI`:

```js run
let user = {
Expand Down Expand Up @@ -291,7 +308,15 @@ delete user.name;
Object.defineProperty(user, "name", { value: "Pete" });
```

<<<<<<< HEAD
>>>>>>> e074a5f825a3d10b0c1e5e82561162f75516d7e3
=======
```smart header="The only attribute change possible: writable true -> false"
There's a minor exception about changing flags.

We can change `writable: true` to `false` for a non-configurable property, thus preventing its value modification (to add another layer of protection). Not the other way around though.
```
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b

## Object.defineProperties

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,13 @@ class CoffeeMachine {
// membuat mesin kopi
let coffeeMachine = new CoffeeMachine(100);

<<<<<<< HEAD
// tambahkan air
coffeeMachine.waterAmount = -10; // Error: Negative water
=======
// add water
coffeeMachine.waterAmount = -10; // _waterAmount will become 0, not -10
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b
```

Sekarang aksesnya terkendali, jadi pengaturan air di bawah nol gagal.
Expand Down
14 changes: 14 additions & 0 deletions 1-js/10-error-handling/2-custom-errors/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ Secara internal, kita akan menggunakan `JSON.parse`. Jika menerima `json` yang s

Fungsi kita `readUser(json)` tidak hanya akan membaca JSON, tetapi juga memeriksa ("memvalidasi") data. Jika tidak ada bidang yang wajib diisi, atau formatnya salah, itu adalah kesalahan. Dan itu bukan `SyntaxError`, karena datanya benar secara sintaksis, tetapi jenis kesalahan lain. Kita akan menyebutnya `ValidationError` dan membuat kelas untuk itu. Kesalahan semacam itu juga harus membawa informasi tentang bidang yang melanggar.

<<<<<<< HEAD
Kelas `ValidationError` kita harus mewarisi dari kelas `Error` bawaan.

Kelas itu sudah ada di dalamnya, tetapi berikut ini kode perkiraannya sehingga kita dapat memahami apa yang kita perluas:
=======
Our `ValidationError` class should inherit from the `Error` class.

The `Error` class is built-in, but here's its approximate code so we can understand what we're extending:
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b

```js
// "Kode semu" untuk kelas Kesalahan bawaan yang ditentukan oleh JavaScript itu sendiri
Expand Down Expand Up @@ -122,11 +128,19 @@ Kita juga bisa melihat `err.name`, seperti ini:

Versi `instanceof` jauh lebih baik, karena di masa mendatang kita akan memperluas `ValidationError`, membuat subtipe darinya, seperti `PropertyRequiredError`. Dan pemeriksaan `instanceof` akan terus berfungsi untuk kelas pewaris baru. Jadi itu bukti masa depan.

<<<<<<< HEAD
Juga penting bahwa jika `catch` menemui kesalahan yang tidak diketahui, maka itu akan ditarik kembali di baris `(**)`. Blok `catch` hanya mengetahui cara menangani validasi dan kesalahan sintaksis, jenis lain (karena kesalahan ketik pada kode atau kesalahan lain yang tidak diketahui) akan gagal.
=======
Also it's important that if `catch` meets an unknown error, then it rethrows it in the line `(**)`. The `catch` block only knows how to handle validation and syntax errors, other kinds (caused by a typo in the code or other unknown reasons) should fall through.
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b

## Warisan lebih lanjut

<<<<<<< HEAD
Kelas `ValidationError` sangat umum. Banyak hal mungkin salah. Properti mungkin tidak ada atau mungkin dalam format yang salah (seperti nilai string untuk `age`). Mari kita buat kelas yang lebih konkret `PropertyRequiredError`, tepatnya untuk properti yang tidak ada. Ini akan membawa informasi tambahan tentang properti yang hilang.
=======
The `ValidationError` class is very generic. Many things may go wrong. The property may be absent or it may be in a wrong format (like a string value for `age` instead of a number). Let's make a more concrete class `PropertyRequiredError`, exactly for absent properties. It will carry additional information about the property that's missing.
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b

```js run
class ValidationError extends Error {
Expand Down
4 changes: 4 additions & 0 deletions 1-js/11-async/01-callbacks/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ function loadScript(src) {
}
```

<<<<<<< HEAD
Fungsi tersebut menambahkan ke dokumen baru, dibuat secara dinamis, tag `<script src="…">` dengan `src` yang diberikan. Browser kemudian secara otomatis memuat dan menjalankannya ketika lengkap.
=======
It inserts into the document a new, dynamically created, tag `<script src="…">` with the given `src`. The browser automatically starts loading it and executes when complete.
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b

Kita bisa menggunakan fungsi tersebut seperti ini:

Expand Down
4 changes: 4 additions & 0 deletions 1-js/11-async/05-promise-api/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ let promise = Promise.all([...promises...]);

`Promise.all` mengambil sebuah array promise (secara teknis bisa menjadi iterable, tetapi biasanya sebuah array) dan mengembalikkan promise baru.

<<<<<<< HEAD
Promise baru resolve ketika semua promise yang terdaftar diselesaikan dan array dari hasil promise menjadi hasilnya itu sendiri.
=======
The new promise resolves when all listed promises are resolved, and the array of their results becomes its result.
>>>>>>> bc08fd1b32285304b14afea12a9deaa10d13452b

Sebagai contoh, `Promise.all` di bawah selesai setelah 3 detik, dan kemudian hasilnya adalah sebuah array `[1, 2, 3]`:

Expand Down
22 changes: 22 additions & 0 deletions 1-js/12-generators-iterators/1-generators/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,28 @@ try {

If we don't catch the error there, then, as usual, it falls through to the outer calling code (if any) and, if uncaught, kills the script.

## generator.return

`generator.return(value)` finishes the generator execution and return the given `value`.

```js
function* gen() {
yield 1;
yield 2;
yield 3;
}

const g = gen();

g.next(); // { value: 1, done: false }
g.return('foo'); // { value: "foo", done: true }
g.next(); // { value: undefined, done: true }
```

If we again use `generator.return()` in a completed generator, it will return that value again ([MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)).

Often we don't use it, as most of time we want to get all returning values, but it can be useful when we want to stop generator in a specific condition.

## Summary

- Generators are created by generator functions `function* f(…) {…}`.
Expand Down
Loading