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
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,10 @@
1
1
# Pengenalan JavaScript
2
2
3
+
<<<<<<< HEAD
3
4
Mari kita lihat apa yang spesial dari JavaScript, apa saja yang bisa kita buat menggunakan JavaScript, dan teknologi apa yang cocok dengan JavaScript.
5
+
=======
6
+
Let's see what's so special about JavaScript, what we can achieve with it, and what other technologies play well with it.
7
+
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
4
8
5
9
## Apa itu JavaScript?
6
10
@@ -129,6 +133,12 @@ Masih banyak lagi. Tentunya, jika kita menggunakan salah satu bahasa yang ditran
129
133
130
134
## Kesimpulan
131
135
136
+
<<<<<<< HEAD
132
137
- JavaScript awalnya diciptakan sebagai bahasa khusus browser, namun sekarang banyak digunakan di lingkungan lain.
133
138
- Sekarang, JavaScript mempunyai posisi unik sebagai bahasa browser paling banyak diadopsi dengan integrasi penuh dengan HTML/CSS.
134
139
- Ada banyak bahasa yang "ditranspile" ke JavaScript dan menyediakan fitur tertentu. Disarankan untuk mempelajari mereka juga, minimal sebentar, setelah menguasai JavaScript.
140
+
=======
141
+
- JavaScript was initially created as a browser-only language, but it is now used in many other environments as well.
142
+
- Today, JavaScript has a unique position as the most widely-adopted browser language with full integration in HTML/CSS.
143
+
- 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.
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/09-comparison/article.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,13 @@ algoritma untuk membandingkan dua string sederhana:
57
57
4. Ulangi sampai string berakhir.
58
58
5. Jika kedua string berakhir pada panjang yang sama, maka mereka sama. Sebaliknya, string lebih panjang yang lebih besar.
59
59
60
+
<<<<<<< HEAD
60
61
Pada contoh di atas, pembandingan `'Z' > 'A'` menghasilkan pada langkah pertama sedangkan string `"Glow"` dan `"Glee"` dibandingkan karakter-demi-karakter:
62
+
=======
63
+
In the first example above, the comparison `'Z' > 'A'` gets to a result at the first step.
64
+
65
+
The second comparison `'Glow'` and `'Glee'` needs more steps as strings are compared character-by-character:
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/12-nullish-coalescing-operator/article.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,11 @@ Hasil dari `a ?? b` adalah:
11
11
- jika `a` belum didefinisikan, maka `b`.
12
12
13
13
14
+
<<<<<<< HEAD
14
15
Dengan kata lain, `??` mengembalikan argumen pertama jika argumen tersebut telah didefinisikan. Sebaliknya, mengembalikan argumen kedua jika argumen pertama belum didefinisikan.
16
+
=======
17
+
In other words, `??` returns the first argument if it's not `null/undefined`. Otherwise, the second one.
18
+
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
15
19
16
20
Operator penggabung nullish bukanlah sesuatu yang benar-benar baru. Operator itu hanyalah sebuah sintaks yang bagus untuk mendapatkan nilai pertama yang telah "didefinisikan" dari dua nilai.
17
21
@@ -39,7 +43,11 @@ let user = "John";
39
43
alert(user ??"Anonymous"); // John
40
44
```
41
45
46
+
<<<<<<< HEAD
42
47
Kita juga bisa menggunakan rentetan `??` untuk mendapatkan nilai yang telah didefinisikan dari sebuah daftar.
48
+
=======
49
+
We can also use a sequence of `??` to select the first value from a list that isn't `null/undefined`.
50
+
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
43
51
44
52
Katakan kita memiliki sebuah data _user_ didalam sebuah variabel `firstName`, `lastName`, atau `nickName`. Semuanya mungkin saya memiliki nilai _undefined_, jika _user_ nya tidak memasukan nilainya.
Operator OR `||` sudah ada sejak awal mula dari Javascript, jadi sudah sejak lama pengembang menggunakan operator _or_ untuk kebutuhan seperti contoh diatas.
79
87
88
+
<<<<<<< HEAD
80
89
Disisi yang lain, operator penggabung nullish `??` baru saja ditambahkan, dan alasan penambahannya adalah karena para pengembang kurang senang dengan `||`.
81
90
82
91
Perbedaan halus, tapi penting adalah:
83
92
- `||` mengembalikan nilai *truthy* pertama.
84
93
- `??` mengembalikan nilai *terdefinisi* pertama.
94
+
=======
95
+
On the other hand, the nullish coalescing operator `??` was added to JavaScript only recently, and the reason for that was that people weren't quite happy with `||`.
96
+
97
+
The important difference between them is that:
98
+
- `||` returns the first *truthy* value.
99
+
- `??` returns the first *defined* value.
100
+
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
85
101
86
102
Dengan kata lain, `||` tidak membedakan antara `false`, `0`, sebuah string kosong `""` dan `null/undefined`. Mereka dilihat sama oleh `||` -- nilai _falsy_. Jika salah satu nilai tersebut berada pada argumen pertama dari `||`, maka kita akan mendapatkan argumen kedua sebagai hasilnya.
87
103
@@ -97,6 +113,7 @@ alert(height || 100); // 100
97
113
alert(height ??100); // 0
98
114
```
99
115
116
+
<<<<<<< HEAD
100
117
Disini, kita memiliki _height_ nol.
101
118
102
119
- Bagian `height ||100` memeriksa `height` sebagai nilai yang _falsy_, dan ternyata benar.
@@ -105,6 +122,14 @@ Disini, kita memiliki _height_ nol.
105
122
- jadi hasil dari `height` adalah "sebagaimana adanya", yang mana adalah `0`.
106
123
107
124
Jika kita asumsikan bahwa _height_ nol adalah nilai yang valid, maka nilainya tidak seharusnya diganti dengan nilai _default_, maka `??` melakukan hal yang benar.
125
+
=======
126
+
- The `height ||100` checks `height` for being a falsy value, and it really is.
127
+
- so the result is the second argument, `100`.
128
+
- The `height ??100` checks `height` for being `null/undefined`, and it's not,
129
+
- so the result is `height` "as is", that is `0`.
130
+
131
+
If the zero height is a valid value, that shouldn't be replaced with the default, then `??` does just the right thing.
132
+
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
108
133
109
134
## Precedence/Hak lebih tinggi
110
135
@@ -156,7 +181,11 @@ alert(x); // 2
156
181
157
182
## Ringkasan
158
183
184
+
<<<<<<< HEAD
159
185
- operator penggabung nullish `??` menyediakan cara yang pendek untuk memilih nilai *defined* dari sebuah daftar.
186
+
=======
187
+
- The nullish coalescing operator `??` provides a short way to choose the first "defined" value from a list.
188
+
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
160
189
161
190
It's used to assign default values to variables:
162
191
Operator nullish digunakan untuk memberikan nilai default kepada sebuah variabel:
@@ -166,5 +195,10 @@ alert(x); // 2
166
195
height = height ??100;
167
196
```
168
197
198
+
<<<<<<< HEAD
169
199
- Operator `??` memiliki nilai *precedence* yang sangat rendah, dan sedikit lebih tinggi dari `?` dan `=`.
170
200
- Dilarang untuk menggunakan operator `??` dengan `\\` atau `&&` tanpa kurung yang jelas.
201
+
=======
202
+
- The operator `??` has a very low precedence, only a bit higher than `?` and `=`, so consider adding parentheses when using it in an expression.
203
+
- It's forbidden to use it with `||` or `&&` without explicit parentheses.
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/18-javascript-specials/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
@@ -144,7 +144,11 @@ Penetapan
144
144
: Ada penetapan simpel: `a = b` dan penetapan kombinasi seperti `a *= 2`.
145
145
146
146
Bitwise
147
+
<<<<<<< HEAD
147
148
: Operator bitwise bekerja dengan integer 32-bit di bit-level paling kecil: lihat [docs](mdn:/JavaScript/Reference/Operators/Bitwise_Operators) ketika mereka dibutuhkan.
149
+
=======
150
+
: Bitwise operators work with 32-bit integers at the lowest, bit-level: see the [docs](mdn:/JavaScript/Guide/Expressions_and_Operators#Bitwise) when they are needed.
151
+
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
148
152
149
153
Kondisional
150
154
: Satu-satunya operator dengan tiga parameter: `cond ? resultA : resultB`. Jika `cond` truthy, mengembalikan `resultA`, jika tidak `resultB`.
Copy file name to clipboardExpand all lines: 1-js/04-object-basics/02-object-copy/article.md
+59Lines changed: 59 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,22 @@
1
+
<<<<<<< HEAD
1
2
# Menyalin objek, referensi
2
3
3
4
Salah satu perbedaan dasar dari objek dan tipe primitif adalah untuk menyimpan dan menyalin "dengan referensi/*by reference*".
4
5
5
6
nilai primitif: string, angka, boolean -- akan disalin "seluruh nilainya".
6
7
7
8
contoh:
9
+
=======
10
+
# Object references and copying
11
+
12
+
One of the fundamental differences of objects versus primitives is that objects are stored and copied "by reference", as opposed to primitive values: strings, numbers, booleans, etc -- that are always copied "as a whole value".
13
+
14
+
That's easy to understand if we look a bit "under a cover" of what happens when we copy a value.
15
+
16
+
Let's start with a primitive, such as a string.
17
+
18
+
Here we put a copy of `message` into `phrase`:
19
+
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
8
20
9
21
```js
10
22
let message ="Hello!";
@@ -15,21 +27,43 @@ Sebagai hasilnya kita punya dua variabel yang berdiri sendiri, dan keduanya meny
15
27
16
28

17
29
30
+
<<<<<<< HEAD
18
31
Objek tidak seperti itu.
19
32
20
33
**Sebuah variabel tidak menyimpan objek itu sendiri, akan tetapi "disimpan didalam memori", dengan kata lain "mereferensi" kepadanya (ke data didalam memori).**
21
34
22
35
Dibawah adalah gambar untuk sebuah objek:
36
+
=======
37
+
Quite an obvious result, right?
38
+
39
+
Objects are not like that.
40
+
41
+
**A variable assigned to an object stores not the object itself, but its "address in memory", in other words "a reference" to it.**
42
+
43
+
Let's look at an example of such variable:
44
+
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
23
45
24
46
```js
25
47
let user = {
26
48
name:"John"
27
49
};
28
50
```
29
51
52
+
And here's how it's actually stored in memory:
53
+
30
54

31
55
56
+
<<<<<<< HEAD
32
57
Disini, objek disimpan di suatu tempat didalam memori. Dan variabel `user` punya "referensi" ke data objek yang berada didalam memori itu.
58
+
=======
59
+
The object is stored somewhere in memory (at the right of the picture), while the `user` variable (at the left) has a "reference" to it.
60
+
61
+
We may think of an object variable, such as `user`, as of a sheet of paper with the address.
62
+
63
+
When we perform actions with the object, e.g. take a property `user.name`, JavaScript engine looks into that address and performs the operation on the actual object.
64
+
65
+
Now here's why it's important.
66
+
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
33
67
34
68
**Ketika sebuah variabel objek disalin -- referensinya akan tersalin, objeknya tidak terduplikasi.**
35
69
@@ -45,7 +79,13 @@ Kita sekarang punya dua variabel, masing-masing mereferensi ke objek yang sama:
45
79
46
80

47
81
82
+
<<<<<<< HEAD
48
83
Kita bisa menggunakan variabel apapun untuk mengakses objek dan memodifikasi konten didalamnya:
84
+
=======
85
+
As you can see, there's still one object, now with two variables that reference it.
86
+
87
+
We can use any variable to access the object and modify its contents:
88
+
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
49
89
50
90
```js run
51
91
let user = { name:'John' };
@@ -59,6 +99,7 @@ admin.name = 'Pete'; // mengganti admin dengan menggunakan "referensi"
59
99
alert(*!*user.name*/!*); //'Pete', perubahan akan terlihat pada "user"
60
100
```
61
101
102
+
<<<<<<< HEAD
62
103
Contoh diatas mendemonstrasikan bahwa disana hanya ada satu objek. Seperti jika kita punya sebuah lemari dengan dua kunci dan satunya (`admin`) digunakan untuk masuk kedalamnya. Lalu, jika kita nanti menggunakan kunci lainnya (`user`) kita bisa melihat perubahannya.
63
104
64
105
## Perbandingan dengan referensi
@@ -68,6 +109,16 @@ Operator pembanding `==` dan pembanding ketat `===` untuk objek bekerja sama saj
68
109
**Dua objek adalah sama jika mereka objek yang sama.**
69
110
70
111
Dibawah adalah dua variabel yang mereferensi ke objek yang sama, dengan demikian mereka sama:
112
+
=======
113
+
114
+
It's just as if we had a cabinet with two keys and used one of them (`admin`) to get into it. Then, if we later use another key (`user`) we can see changes.
115
+
116
+
## Comparison by reference
117
+
118
+
Two objects are equal only if they are the same object.
119
+
120
+
For instance, here `a` and `b` reference the same object, thus they are equal:
121
+
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
71
122
72
123
```js run
73
124
let a = {};
@@ -77,7 +128,11 @@ alert( a == b ); // true, kedua variabel mereferensi ke objek yang sama
77
128
alert( a === b ); // true
78
129
```
79
130
131
+
<<<<<<< HEAD
80
132
Dan dibawah adalah dua objek yang berdiri sendiri, tidaklah sama, walaupun keduanya kosong:
133
+
=======
134
+
And here two independent objects are not equal, even though they look alike (both are empty):
135
+
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
81
136
82
137
```js run
83
138
let a = {};
@@ -86,7 +141,11 @@ let b = {}; // dua objek yang berdiri sendiri
86
141
alert( a == b ); // false
87
142
```
88
143
144
+
<<<<<<< HEAD
89
145
Untuk perbandingan seperti `obj1 > obj2` atau untuk perbandingan dengan sebuah nilai primitif `obj ==5`, objek akan diubah dahulu menjadi primitif. Kita akan belajar bagaimana perubahan objek sebentar lagi, akan tetapi sebenarnya, perbandingan seperti itu muncul sangat jarang, biasanya hanya sebuah hasil dari kesalahan koding.
146
+
=======
147
+
For comparisons like `obj1 > obj2` or for a comparison against a primitive `obj ==5`, objects are converted to primitives. We'll study how object conversions work very soon, but to tell the truth, such comparisons are needed very rarely, usually they appear as a result of a programming mistake.
0 commit comments