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/03-code-quality/06-polyfills/article.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,12 @@ Sebenarnya, ada dua bagian dari Babel:
29
29
30
30
Seperti disebutkan diatas, JavaScript adalah sebuah bahasa pemrograman yang sangat dinamis. Skrip-skrip baru terus ditambahkan kedalam JavaScript dengan tujuan untuk membuat fungsi-fungsi baru menjadi dapat dibaca oleh penerjemah JavaScript standar.
31
31
32
+
<<<<<<< HEAD
32
33
Skrip-skrip tambahan inilah yang disebut Polyfill. Skrip-skrip ini biasanya berupa fungsi-fungsi yang bertujuan menambah atau memodifikasi perbendaharaan JavaScript standar agar mampu mengenal fitur-fitur modern.
34
+
=======
35
+
New language features may include not only syntax constructs, but also built-in functions.
36
+
The transpiler rewrites the code, transforming syntax constructs into older ones. But as for new built-in functions, we need to implement them. JavaScript is a highly dynamic language, scripts may add/modify any functions, so that they behave according to the modern standard.
Copy file name to clipboardExpand all lines: 1-js/04-object-basics/03-garbage-collection/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
@@ -23,7 +23,11 @@ Sederhananya, sebuah nilai yang "terjangkau" adalah mereka yang masih dapat diak
23
23
24
24
2. Nilai lainnya dianggap terjangkau jika dapat dijangkau dari sebuah _root_ melalui sebuah rujukkan atau rantai rujukkan.
25
25
26
+
<<<<<<< HEAD
26
27
Contoh, jika terdapat sebuah objek didalam global variabel, dan objek tersebut memiliki sebuah properti yang mereferensi objek lain, objek itu dianggap dapat dijangkau. Dan referensinya juga bisa dijangkau. Contoh lengkap dibawah ini.
28
+
=======
29
+
For instance, if there's an object in a global variable, and that object has a property referencing another object, *that* object is considered reachable. And those that it references are also reachable. Detailed examples to follow.
30
+
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d
27
31
28
32
Ada sebuah _background process_ di _engine_ JavaScript yang disebut [_garbage collector_](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)). Ia mengamati seluruh objek dan menyingkirkan semua yang sudah tak terjangkau.
Copy file name to clipboardExpand all lines: 1-js/04-object-basics/07-optional-chaining/article.md
+51-13Lines changed: 51 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,15 +14,21 @@ The optional chaining `?.` is a safe way to access nested object properties, eve
14
14
15
15
Jika kamu baru saja membaca tutorial dan belajar Javascript, mungkin masalahnya belum ketemu, tapi itu sudah biasa.
16
16
17
+
<<<<<<< HEAD
17
18
<<<<<<< HEAD
18
19
Contoh, beberapa dari pengguna kita punya alamat, tapi beberapa tidak memberikannya. Lalu kita tidak bisa dengan mudah menggunakan `user.address.street`:
19
20
20
21
```js run
21
22
let user = {}; // penggunanya tidak memiliki alamat
22
23
=======
23
24
As an example, consider objects for user data. Mostof our users have addresses in`user.address` property, with the street `user.address.street`, but some did not provide them.
25
+
=======
26
+
As an example, let's say we have `user` objects that hold the information about our users.
27
+
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d
28
+
29
+
Most of our users have addresses in `user.address` property, with the street `user.address.street`, but some did not provide them.
24
30
25
-
In such case, when we attempt to get `user.address.street`, we may get an error:
31
+
In such case, when we attempt to get `user.address.street`, and the user happens to be without an address, we get an error:
26
32
27
33
```js run
28
34
let user = {}; // a user without "address" property
@@ -31,6 +37,7 @@ let user = {}; // a user without "address" property
31
37
alert(user.address.street); // Error!
32
38
```
33
39
40
+
<<<<<<< HEAD
34
41
<<<<<<< HEAD
35
42
Atau, didalam pengembangan, kita ingin untuk mendapatkan informasi tentang sebuah elemen didalam halaman, tapi elemennya tidak ada:
36
43
@@ -44,27 +51,32 @@ Sebelum `?.` muncul, operator `&&` digunakan untuk berurusan dengan hal itu.
44
51
Contoh:
45
52
=======
46
53
That's the expected result, JavaScript works like this. As`user.address` is `undefined`, the attempt to get `user.address.street` fails with an error. Although, in many practical cases we'd prefer to get `undefined` instead of an error here (meaning "no street").
54
+
=======
55
+
That's the expected result. JavaScript works like this. As`user.address` is `undefined`, an attempt to get `user.address.street` fails with an error.
56
+
57
+
In many practical cases we'd prefer to get `undefined` instead of an error here (meaning "no street").
58
+
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d
47
59
48
-
...And another example. In the web development, we may need the information about an element on thepage. Theelement is returned by `document.querySelector('.elem')`, and the catch is again - that it sometimes doesn't exist:
60
+
...And another example. In the web development, we can get an object that corresponds to a web pageelement using a special method call, such as `document.querySelector('.elem')`, and it returns `null` when there's no such element.
49
61
50
62
```js run
51
-
// the result of the call document.querySelector('.elem') may be an object or null
63
+
// document.querySelector('.elem') is null if there's no element
52
64
let html = document.querySelector('.elem').innerHTML; // error if it's null
53
65
```
54
66
55
-
Once again, we may want to avoid the error in such case.
67
+
Once again, if the element doesn't exist, we'll get an error accessing `.innerHTML`of`null`. Andin some cases, when the absence of the element is normal, we'd like to avoid the error and just accept `html = null` as the result.
56
68
57
69
How can we do this?
58
70
59
-
The obvious solution would be to check the value using `if` or the conditional operator `?`, before accessing it, like this:
71
+
The obvious solution would be to check the value using `if` or the conditional operator `?`, before accessing its property, like this:
...But that's quite inelegant. As you can see, the `user.address` is duplicated in the code. For more deeply nested properties, that becomes a problem.
79
+
It works, there's no error...But it's quite inelegant. As you can see, the `"user.address"` appears twice in the code. For more deeply nested properties, that becomes a problem as more repetitions are required.
68
80
69
81
E.g. let's try getting `user.address.street.name`.
70
82
@@ -76,10 +88,14 @@ let user = {}; // user has no address
Perhatikan: sintaks `?.` membuat nilai opsional sebelumnya, tapi tidak setelahnya.
134
165
166
+
<<<<<<< HEAD
135
167
<<<<<<< HEAD
136
168
Didalam contoh diatas, `user?.` membolehkan hanya `user` untuk `null/undefined`.
137
169
=======
@@ -142,6 +174,9 @@ Disisi lain, jika `user` ada, lalu itu harus memiliki properti `user.address`, s
142
174
143
175
```warn header="Jangan terlalu berlebihan menggunakan rantai opsional"
144
176
Kita harus menggunakan `?.` hanya dimana sesuatu itu tidak apa-apa bila tidak ada.
177
+
=======
178
+
E.g. in `user?.address.street.name` the `?.` allows `user` to be `null/undefined`, but it's all it does. Further properties are accessed in a regular way. If we want some of them to be optional, then we'll need to replace more `.` with `?.`.
179
+
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d
145
180
146
181
<<<<<<< HEAD
147
182
Contoh, jika berdasarkan logika koding kita objek `user` harus ada, tapi `address` bersifat opsional, lalu `user.address?.street` akan lebih baik.
@@ -210,17 +245,20 @@ Contoh, `?.()` digunakan untuk memanggil fungsi yang mungkin saja tidak ada.
210
245
Di kode dibawah, beberapa user mungkin memiliki method `admin`, dan beberapa tidak:
Copy file name to clipboardExpand all lines: 1-js/05-data-types/02-number/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
@@ -406,7 +406,11 @@ Beberapa contoh:
406
406
alert( Math.pow(2, 10) ); // 2 in power 10 = 1024
407
407
```
408
408
409
+
<<<<<<<HEAD
409
410
Ada lebih banyak fungsi dan konstanta dalam objek `Math`, termasuk trigonometri, yang dapat Anda temukan di [docs untuk objek Math](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Math).
411
+
=======
412
+
There are more functions and constants in`Math` object, including trigonometry, which you can find in the [docs for the Math object](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Math).
Copy file name to clipboardExpand all lines: 1-js/06-advanced-functions/04-var/article.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,11 @@ function sayHi() {
78
78
}
79
79
80
80
sayHi();
81
+
<<<<<<<HEAD
81
82
alert(phrase); // Error: frasa tidak terdefinisi (periksa Developer Console)
83
+
=======
84
+
alert(phrase); // Error: phrase is not defined
85
+
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d
82
86
```
83
87
84
88
Seperti yang bisa kita lihat `var` menembus `if`, `for` atau blok kode lainnya. Itu karena sejak dahulu di blok Javascript tidak memiliki Lingkungan Leksikal. dan `var` adalah sisanya.
@@ -267,8 +271,13 @@ Dalam semua kasus diatas kami mendeklarasikan sebuah Ekspresi fungsi dan menjala
267
271
268
272
Ada dua perbedaan utama dari `var` dibandingkan dengan `let/const`;
269
273
274
+
<<<<<<< HEAD
270
275
1.`var` variabel tidak memiliki ruang lingkup blok, mereka terlihat minimum pada tingkat fungsi.
271
276
2. Deklarasi `var` diproses saat fungsi dimulai (skrip dimulai untuk global).
277
+
=======
278
+
1.`var` variables have no block scope, their visibility is scoped to current function, or global, if declared outside function.
279
+
2.`var` declarations are processed at function start (script start for globals).
280
+
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d
272
281
273
282
Ada satu perbedaan kecil terkait objek global, yang akan kita bahas pada bab selanjutnya.
Copy file name to clipboardExpand all lines: 1-js/06-advanced-functions/05-global-object/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
@@ -5,11 +5,15 @@ 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
<<<<<<< HEAD
9
10
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
=======
11
12
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
13
>>>>>>> f830bc5d9454d85829e011d914f215eb5896579a
14
+
=======
15
+
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.
16
+
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d
13
17
14
18
Kita akan memakai `window` disini, dengan anggapan bahwa lingkungan kita adalah browser. Jika script kamu mungkin digunakan di lingkungan lain, lebih baik menggunakan `globalThis`.
Mohon jangan bergantung dengan itu! Perilaku ini ada untuk alasan kompatibilitas. Script modern menggunakan [JavaScript modules](info:modules) dimana hal-hal tersebut tidak terjadi.
38
+
=======
39
+
The same effect have function declarations (statements with `function` keyword in the main code flow, not function expressions).
40
+
41
+
Please don't rely on that! This behavior exists for compatibility reasons. Modern scripts use [JavaScript modules](info:modules) where such thing doesn't happen.
42
+
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d
33
43
34
44
Jika kita menggunakan `let`, hal tersebut tidak akan terjadi:
Copy file name to clipboardExpand all lines: 1-js/06-advanced-functions/06-function-object/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
@@ -347,7 +347,11 @@ Jika fungsinya di deklarasikan sebagai ekspresi fungsi (tidak didalam alur kode
347
347
348
348
Juga, fungsi mungkin memiliki properti tambahan. Beberapa librari Javascript yang cukup terkenal banyak menggunakan fitur ini.
349
349
350
+
<<<<<<< HEAD
350
351
Mereka membuat sebuah fungsi "utama" dan mengkaitkannya dengan fungsi "pembantu". Contoh librari [jQuery](https://jquery.com) menciptakan fungsi bernama `$`. Librari The [lodash](https://lodash.com) membuat sebuah fungsi `_` dan lalu menambahkan `_.clone`, `_.keyBy`dan properti lainnya kedalamnya (lihat [dokumentasinya](https://lodash.com/docs) ketika kamu mau tau lebih dalam). Sebenarnya, mereka melakukannya untuk mengurangi penggunaan dari ruang global, jadi librari tunggal itu hanya menggunakan satu variabel global. Itu mengurangi kemungkinan dari konflik penamaan variabel.
352
+
=======
353
+
They create a "main" function and attach many other "helper" functions to it. For instance, the [jQuery](https://jquery.com) library creates a function named `$`. The [lodash](https://lodash.com) library creates a function `_`, and then adds `_.clone`, `_.keyBy` and other properties to it (see the [docs](https://lodash.com/docs) when you want to learn more about them). Actually, they do it to lessen their pollution of the global space, so that a single library gives only one global variable. That reduces the possibility of naming conflicts.
354
+
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d
351
355
352
356
353
357
Jadi, sebuah fungsi bisa melakukan hal-hal yang berguna dengan dirinya-sendiri dan juga membawa setumpuk fungsionalitas didalam propertinya sendiri.
Copy file name to clipboardExpand all lines: 1-js/06-advanced-functions/07-new-function/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
@@ -92,7 +92,11 @@ Bagaimana jika itu bisa mengakses variabel luar?
92
92
93
93
Masalahnya adalah saat Javascript belum dipublikasikan untuk produksi, itu akan dikompresi menggunakan *minifier* -- sebuah program spesial yang mengecilkan ukuran kode dengan menghapus komentar-komentar, spasi dan -- yang paling penting, menamai variabel lokal menjadi lebih pendek.
94
94
95
+
<<<<<<< HEAD
95
96
Contoh, jika sebuah fungsi mempunyai `let userName`, minifier akan mengganti itu dengan `let a` (atau huruf lainnya jika tidak hurufnya tidak tersedia), dan melakukannya dimanapun. Sebenarnya itu adalah yang yang aman untuk dilakukan, karena variabelnya lokal, tidak ada sesuatu dari luar fungsinya yang bisa mengaksesnya. Dan didalam fungsinya, minifier mengganti seluruh penamaan variabelnya. Minifier cukup pintar, mereka menganalisa struktur kodenya, jadi mereka tidak akan merusak apapun. Minifier bukanlah hal bodoh yang hanya akan mencari-dan-mengganti.
97
+
=======
98
+
For instance, if a function has `let userName`, minifier replaces it with `let a` (or another letter if this one is occupied), and does it everywhere. That's usually a safe thing to do, because the variable is local, nothing outside the function can access it. And inside the function, minifier replaces every mention of it. Minifiers are smart, they analyze the code structure, so they don't break anything. They're not just a dumb find-and-replace.
99
+
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d
96
100
97
101
Jadi jika `new Function` mempunyai akses ke variabel luar, itu tidak akan bisa menemukan `userName` yang telah dinamai ulang.
0 commit comments