Skip to content

Commit a815e0a

Browse files
committed
merging all conflicts
2 parents 9079d09 + fb4fc33 commit a815e0a

File tree

31 files changed

+391
-54
lines changed

31 files changed

+391
-54
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ Browser punya engine yang tertanam didalamnya yang disebut "JavaScript virtual m
2424

2525
Tiap engine punya *codename*-nya sendiri. Misalnya:
2626

27+
<<<<<<< HEAD
2728
- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- di Chrome dan Opera.
2829
- [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) -- di Firefox.
2930
- ...Ada juga codename lain seperti "Trident" dan "Chakra" untuk versi berbeda dari IE, "ChakraCore" untuk Microsoft Edge, "Nitro" dan "SquirrelFish" untuk Safari, dll.
31+
=======
32+
- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- in Chrome and Opera.
33+
- [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) -- in Firefox.
34+
- ...There are other codenames like "Chakra" for IE, "JavaScriptCore", "Nitro" and "SquirrelFish" for Safari, etc.
35+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
3036
3137
Istilah di atas sebaiknya diingat karena akan sering digunakan dalam artikel para developer di internet. Kita akan menggunakannya juga. Misalnya, jika "fitur X didukung V8", kemungkinan ia bisa jalan di Chrome dan Opera.
3238

1-js/02-first-steps/02-structure/article.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ alert(3 +
4646
+ 2);
4747
```
4848

49+
<<<<<<< HEAD
4950
Output dari kode itu adalah `6` karena JavaScript tak menyisipkan titik koma di sini. Sudah jelas sekali bahwa barisnya selesai dengan tanda plus `"+"`, sehingga itu menjadi "expresi tak lengkap", jadi tak butuh titik koma. Dan dalam hal ini memang seperti itu.
51+
=======
52+
The code outputs `6` because JavaScript does not insert semicolons here. It is intuitively obvious that if the line ends with a plus `"+"`, then it is an "incomplete expression", so a semicolon there would be incorrect. And in this case, that works as intended.
53+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
5054
5155
**Tapi ada situasi di mana JavaScript "gagal" mengasumsi titik koma di mana itu benar-benar dibutuhkan.**
5256

@@ -56,40 +60,63 @@ Galat yang muncul pada kasus ini agak sulit dicari dan dibetulkan.
5660
Jika kamu penasaran untuk melihat contoh konkrit dari galat ini, cek kode ini:
5761
5862
```js run
59-
[1, 2].forEach(alert)
63+
alert("Hello");
64+
65+
[1, 2].forEach(alert);
6066
```
6167
68+
<<<<<<< HEAD
6269
Untuk sekarang tak usah memikirkan makna kurung siku `[]` dan `forEach`. Kita akan mempelajari mereka nanti. Untuk sekarang, ingat hasil kode tersebut: yaitu `1` lalu `2`.
6370
6471
Sekarang, ayo kita tambahkan `alert` sebelum kodenya *tanpa* diikuti titik koma:
72+
=======
73+
No need to think about the meaning of the brackets `[]` and `forEach` yet. We'll study them later. For now, just remember the result of running the code: it shows `Hello`, then `1`, then `2`.
74+
75+
Now let's remove the semicolon after the `alert`:
76+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
6577
6678
```js run no-beautify
67-
alert("There will be an error")
79+
alert("Hello")
6880
69-
[1, 2].forEach(alert)
81+
[1, 2].forEach(alert);
7082
```
7183
84+
<<<<<<< HEAD
7285
Sekarang jika kita menjalankan kodenya, hanya `alert` pertama yang tampil dan kemudian galat!
7386
7487
Tapi semua akan baik-baik saja jika kita menambahkan titik koma setelah `alert`:
7588
```js run
7689
alert("All fine now");
90+
=======
91+
The difference compared to the code above is only one character: the semicolon at the end of the first line is gone.
92+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
7793
78-
[1, 2].forEach(alert)
79-
```
94+
If we run this code, only the first `Hello` shows (and there's an error, you may need to open the console to see it). There are no numbers any more.
8095
96+
<<<<<<< HEAD
8197
Sekarang kita punya pesan "All fine now" diikuti dengan `1` dan `2`.
8298
8399
84100
Galat muncul pada varian tanpa titik koma karena JavaScript tak mengasumsikan titik koma sebelum kurung siku `[...]`.
85101
86102
Jadi, karena titik koma tidak otomatis disisipkan, kode di contoh pertama diperlakukan sebagai pernyataan tunggal. Inilah cara engine melihatnya:
103+
=======
104+
That's because JavaScript does not assume a semicolon before square brackets `[...]`. So, the code in the last example is treated as a single statement.
105+
106+
Here's how the engine sees it:
107+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
87108
88109
```js run no-beautify
89-
alert("There will be an error")[1, 2].forEach(alert)
110+
alert("Hello")[1, 2].forEach(alert);
90111
```
91112
113+
<<<<<<< HEAD
92114
Tapi itu harus jadi dua pernyataan terpisah, bukan satu. Penyatuan macam ini salah pada kasus ini, makanya galat. Ini bisa terjadi dalam situasi lain.
115+
=======
116+
Looks weird, right? Such merging in this case is just wrong. We need to put a semicolon after `alert` for the code to work correctly.
117+
118+
This can happen in other situations also.
119+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
93120
````
94121

95122
Kami sarankan menaruh titik koma di antara pernyataan meski mereka dipisahkan garis baru. Ini aturan yang diterima secara luas oleh komunitas. Harap diingat sekali lagi bahwa -- *bisa saja* menanggalkan titik koma di banyak kesempatan. Tapi akan lebih aman -- terutama untuk pemula -- untuk menggunakan mereka.

1-js/02-first-steps/05-types/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Nilai numerik spesial formalnya merupakan bagian dari tipe "number". Tentu saja
6464

6565
Kita akan melihat lebih tentang cara bekerja dengan angka di bab <info:number>.
6666

67-
## BigInt
67+
## BigInt [#bigint-type]
6868

6969
Didalam Javascript, tipe data "number" tidak bisa mengandung nilai lebih dari <code>(2<sup>53</sup>-1)</code> (sama dengan `9007199254740991`) atau kurang dari <code>-(2<sup>53</sup>-1)</code>. Itu adalah batasan teknik yang dibuat.
7070

1-js/02-first-steps/08-operators/article.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Contoh:
6868

6969
```js run
7070
<<<<<<< HEAD
71+
<<<<<<< HEAD
7172
alert( 2 ** 2 ); // 4 (2 dikalikan dengan nilai itu sendiri sebanyak 2 kali)
7273
alert( 2 ** 3 ); // 8 (2 * 2 * 2, 3 kali)
7374
alert( 2 ** 4 ); // 16 (2 * 2 * 2 * 2, 4 kali)
@@ -78,6 +79,10 @@ Contoh, akar kuadrat adalah eksponen dari `1/2`:
7879
=======
7980
alert( 2 ** 2 ); // 2² = 4
8081
alert( 2 ** 3 ); // 2³ = 8
82+
=======
83+
alert( 2 ** 2 ); // 2² = 4
84+
alert( 2 ** 3 ); // 2³ = 8
85+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
8186
alert( 2 ** 4 ); // 2⁴ = 16
8287
```
8388

1-js/02-first-steps/15-function-basics/article.md

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ function showMessage() {
2020
}
2121
```
2222

23+
<<<<<<< HEAD
2324
Katakunci `fungsi` ditulis duluan, lalu *nama fungsinya*, kemudian daftar semua *parameter* antara tanda kurung () (pada contoh di atas, tanda kurung kosong) dan bagian terakhir adalah fungsi kode, yang juga disebut sebagai "badan fungsi", antara kurung kurawal {}.
25+
=======
26+
The `function` keyword goes first, then goes the *name of the function*, then a list of *parameters* between the parentheses (comma-separated, empty in the example above, we'll see examples later) and finally the code of the function, also named "the function body", between curly braces.
27+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
2428
2529
```js
26-
function name(parameters) {
30+
function name(parameter1, parameter2, ... parameterN) {
2731
...body...
2832
}
2933
```
@@ -137,26 +141,34 @@ Ini menjadi suatu cara yang baik untuk mengurangi penggunaan variabel global. Ko
137141

138142
## Parameters
139143

144+
<<<<<<< HEAD
140145
Kita dapat meloloskan data yang begitu acak kepada fungsi sebagai parameter (disebut juga sebagai *fungsi argumen*).
146+
=======
147+
We can pass arbitrary data to functions using parameters.
148+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
141149
142150
Pada contoh di bawah, fungsi memiliki dua paramter: `from` dan `text`.
143151

144152
```js run
145-
function showMessage(*!*from, text*/!*) { // arguments: from, text
153+
function showMessage(*!*from, text*/!*) { // parameters: from, text
146154
alert(from + ': ' + text);
147155
}
148156

157+
<<<<<<< HEAD
149158
*!*
150159
showMessage('Ann', 'Hello!'); // Ann: Hallo! (*)
151160
showMessage('Ann', "What's up?"); // Ann: Ada apa? (**)
152161
*/!*
162+
=======
163+
*!*showMessage('Ann', 'Hello!');*/!* // Ann: Hello! (*)
164+
*!*showMessage('Ann', "What's up?");*/!* // Ann: What's up? (**)
165+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
153166
```
154167
155168
Ketika fungsi dipanggil pada penanda `(*)` dan `(**)`, nilai yang diberikan dipindahkan ke variabel lokal `from` dan `text`. Lalu fungsi menggunakan nilai-nilai tersebut.
156169
157170
Ini terdapat satu lagi contoh: kita memiliki variabel `from` dan memindahkannya ke fungsi. Dengan catatan: fungsi akan mengubah `from`, tapi perubahan ini tidak akan terlihat di luar fungsi, karena sebuah fungsi akan selalu mendapatkan salinan nilai:
158171
159-
160172
```js run
161173
function showMessage(from, text) {
162174
@@ -175,23 +187,47 @@ showMessage(from, "Hello"); // *Ann*: Hallo
175187
alert( from ); // Ann
176188
```
177189
190+
<<<<<<< HEAD
178191
## Nilai default
179192
180193
Jika parameter tidak diberi nilai, maka nilainya menjadi `undefined`.
194+
=======
195+
When a value is passed as a function parameter, it's also called an *argument*.
196+
197+
In other words, to put these terms straight:
198+
199+
- A parameter is the variable listed inside the parentheses in the function declaration (it's a declaration time term)
200+
- An argument is the value that is passed to the function when it is called (it's a call time term).
201+
202+
We declare functions listing their parameters, then call them passing arguments.
203+
204+
In the example above, one might say: "the function `sayMessage` is declared with two parameters, then called with two arguments: `from` and `"Hello"`".
205+
206+
207+
## Default values
208+
209+
If a function is called, but an argument is not provided, then the corresponding value becomes `undefined`.
210+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
181211

182212
Sebagai gambaran, fungsi yang telah tersebut di atas `showMessage(from, text)` dapat dipanggil dengan argumen tunggal:
183213

184214
```js
185215
showMessage("Ann");
186216
```
187217

218+
<<<<<<< HEAD
188219
<<<<<<< HEAD
189220
Itu tidak terjadi kesalahan. Malah pemanggilan tersebut akan menghasilkan `"Ann: undefined"`. Tidak ada argumen untuk parameter `text`, jadi ini diasumsikan bahwa `text === undefined`.
190221
=======
191222
That's not an error. Such a call would output `"*Ann*: undefined"`. There's no `text`, so it's assumed that `text === undefined`.
192223
>>>>>>> f489145731a45df6e369a3c063e52250f3f0061d
193224

194225
Jika kita ingin menggunakan suatu `text` "default" pada kasus ini, lalu kita dapat menentukannya setelah `=`:
226+
=======
227+
That's not an error. Such a call would output `"*Ann*: undefined"`. As the value for `text` isn't passed, it becomes `undefined`.
228+
229+
We can specify the so-called "default" (to use if omitted) value for a parameter in the function declaration, using `=`:
230+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
195231

196232
```js run
197233
function showMessage(from, *!*text = "no text given"*/!*) {
@@ -215,19 +251,33 @@ function showMessage(from, text = anotherFunction()) {
215251
```smart header="Evaluasi parameter default"
216252
Di Javascript, parameter default dievaluasi tiap kali fungsi dipanggil tanpa parameter.
217253

254+
<<<<<<< HEAD
218255
Pada contoh di atas, `anotherFunction()` dipanggil tiap kali `showMessage()` dipanggil tanpa parameter `text`.
256+
=======
257+
In the example above, `anotherFunction()` isn't called at all, if the `text` parameter is provided.
258+
259+
On the other hand, it's independently called every time when `text` is missing.
260+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
219261
```
220262
221263
### Alternatif nilai default parameter
222264
265+
<<<<<<< HEAD
223266
Terkadang akan dapat dimengerti untuk memberikan nilai default untuk variabel bukan didalam deklarasi fungsi, tapi di tahap selanjutnya, didalam proses eksekusinya.
224267
225268
Untuk memeriksa parameter yang tidak ada, kita bisa membandingkannya dengan `undefined`:
269+
=======
270+
Sometimes it makes sense to assign default values for parameters not in the function declaration, but at a later stage.
271+
272+
We can check if the parameter is passed during the function execution, by comparing it with `undefined`:
273+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
226274
227275
```js run
228276
function showMessage(text) {
277+
// ...
278+
229279
*!*
230-
if (text === undefined) {
280+
if (text === undefined) { // if the parameter is missing
231281
text = 'empty message';
232282
}
233283
*/!*
@@ -238,21 +288,35 @@ function showMessage(text) {
238288
showMessage(); // empty message
239289
```
240290
291+
<<<<<<< HEAD
241292
...Atau kita bisa menggunakan operator `||`:
242293
243294
```js
244295
// jika teks parameter tidak ada atau "", set variabel ke 'empty'
296+
=======
297+
...Or we could use the `??` operator:
298+
299+
```js
300+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
245301
function showMessage(text) {
302+
// if text is undefined or otherwise falsy, set it to 'empty'
246303
text = text || 'empty';
247304
...
248305
}
249306
```
250307

308+
<<<<<<< HEAD
251309
Javascript yang modern mendukung [nullish coalescing operator/operator penggabung nullish](info:nullish-coalescing-operator) `??`, akan lebih baik jika nilai falsy, seperti `0`, dianggap biasa:
252310

253311
```js run
254312
// jika tidak ada parameter "count", tampilkan "unknown"
313+
=======
314+
Modern JavaScript engines support the [nullish coalescing operator](info:nullish-coalescing-operator) `??`, it's better when most falsy values, such as `0`, should be considered "normal":
315+
316+
```js run
317+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
255318
function showCount(count) {
319+
// if count is undefined or null, show "unknown"
256320
alert(count ?? "unknown");
257321
}
258322

1-js/03-code-quality/01-debugging-chrome/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
<<<<<<< HEAD
12
# Mendebug di Chrome
3+
=======
4+
# Debugging in the browser
5+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
26
37
Sebelum menulis kode lebih komplex, ayo kita bahas tentang mendebug.
48

1-js/04-object-basics/06-constructor-new/article.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,21 @@ Sekarang jika kita ingin membuat *user* lain, kita bisa memanggil `new User("Ann
6464

6565
Itulah tujuan utama dari konstruktor -- untuk mengimplementasikan kode pembuatan objek yang dapat dipakai ulang (*reusable*).
6666

67+
<<<<<<< HEAD
6768
Mari ingat sekali lagi -- secara teknis, fungsi apapun dapat digunakan sebagai sebuah konstruktor. Hal tersebut berarti: fungsi apapun dapat dijalankan dengan `new`, dan bisa mengeksekusi algoritma di atas. "Huruf kapital dulu" adalah kesepakatan umum, untuk membuatnya lebih jelas bahwa sebuah fungsi untuk dijalankan dengan `new`.
6869

6970
````smart header="function() { ... } baru"
7071
Jika kita memiliki banyak baris kode tentang pembuatan sebuah objek tunggal yang kompleks, kita dapat membungkus kode tersebut dalam fungsi konstruktor, seperti ini:
72+
=======
73+
Let's note once again -- technically, any function (except arrow functions, as they don't have `this`) can be used as a constructor. It can be run with `new`, and it will execute the algorithm above. The "capital letter first" is a common agreement, to make it clear that a function is to be run with `new`.
74+
75+
````smart header="new function() { ... }"
76+
If we have many lines of code all about creation of a single complex object, we can wrap them in an immediately called constructor function, like this:
77+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
7178
7279
```js
73-
let user = new function() {
80+
// create a function and immediately call it with new
81+
let user = new function() {
7482
this.name = "John";
7583
this.isAdmin = false;
7684
@@ -80,7 +88,11 @@ let user = new function() {
8088
};
8189
```
8290
91+
<<<<<<< HEAD
8392
Konstruktor tersebut tidak dapat dipanggil lagi, karena tidak disimpan dimanapun, hanya dibuat dan dipanggil. Jadi trik ini ditujukan untuk mengenkapsulasi kode yang mengonstruksi objek tunggal, tanpa penggunaan di masa yang akan datang.
93+
=======
94+
This constructor can't be called again, because it is not saved anywhere, just created and called. So this trick aims to encapsulate the code that constructs the single object, without future reuse.
95+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
8496
````
8597

8698
## Constructor mode test: new.target

0 commit comments

Comments
 (0)