Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
ca1ef0d
FIX: change ; to ,
leviding Oct 18, 2020
649539e
FIX: delete extra space
leviding Oct 18, 2020
4131b29
FIX: delete extra space
leviding Oct 19, 2020
030decc
Update article.md
iliakan Oct 20, 2020
9d4a69d
Update article.md
iliakan Oct 20, 2020
c634301
Update article.md
iliakan Oct 20, 2020
e74295c
Update article.md
iliakan Oct 20, 2020
959dc23
Update article.md
iliakan Oct 20, 2020
7487ce9
Update article.md
iliakan Oct 20, 2020
c69ca0d
Update article.md
iliakan Oct 20, 2020
44a17a3
Update article.md
iliakan Oct 20, 2020
d4120a0
Update article.md
iliakan Oct 20, 2020
fca113b
Update article.md
iliakan Oct 20, 2020
d961910
Update article.md
iliakan Oct 20, 2020
9ad8f66
Update article.md
iliakan Oct 20, 2020
e92bbb1
Update article.md
iliakan Oct 20, 2020
1197b01
Update article.md
iliakan Oct 20, 2020
614c5ff
Update article.md
iliakan Oct 20, 2020
6393a9f
Update article.md
iliakan Oct 20, 2020
a502398
Update article.md
iliakan Oct 20, 2020
24ff585
Update article.md
iliakan Oct 20, 2020
971a32e
Update article.md
iliakan Oct 20, 2020
7d05ada
Mention HTML attribute events in the summary
aruku Oct 19, 2020
ad3a7cc
Fix typo (I think)
aruku Oct 19, 2020
9b2f866
Fix typo in 1.4.7 (optional chaining)
vsemozhetbyt Oct 20, 2020
b0c60e3
Remove possibly outdated comment
vsemozhetbyt Oct 20, 2020
ae72328
Merge pull request #2222 from vsemozhetbyt/patch-11
iliakan Oct 20, 2020
4a75ea4
Mention function declaration in 1.6.5 (global object)
vsemozhetbyt Oct 21, 2020
e8455bc
Fix a typo in 1.6.6 (function object, NFE)
vsemozhetbyt Oct 21, 2020
518daec
Fix possible typo in 1.6.7 ("new Function" syntax)
vsemozhetbyt Oct 22, 2020
ad49592
Fix typos, specify link in 1.6.8 (Scheduling)
vsemozhetbyt Oct 22, 2020
c8edd84
Merge pull request #2213 from leviding/patch-28
iliakan Oct 22, 2020
3897d24
Merge pull request #2214 from leviding/patch-29
iliakan Oct 22, 2020
a10d94d
Merge pull request #2218 from aruku/aruku-patch-1
iliakan Oct 22, 2020
bd0fbbe
Merge pull request #2219 from vsemozhetbyt/patch-9
iliakan Oct 22, 2020
7ddddd2
Merge pull request #2224 from vsemozhetbyt/patch-11
iliakan Oct 22, 2020
decb6a2
Merge pull request #2226 from vsemozhetbyt/patch-12
iliakan Oct 22, 2020
44252ad
Merge pull request #2228 from vsemozhetbyt/patch-13
iliakan Oct 22, 2020
2d5be7b
Merge pull request #2229 from vsemozhetbyt/patch-14
iliakan Oct 22, 2020
58ee49a
Update task.md
Herrera-pgoat Oct 22, 2020
567d911
Minor clarification on WeakMap and WeakSet
DawidKopys Oct 24, 2020
2e05706
Replace rules.indent array with number
mikemitchell574 Oct 24, 2020
901e5ef
Update topic sentence
mikemitchell574 Oct 25, 2020
7ee9c6a
Fix links in 1.8.4 (Prototype methods)
vsemozhetbyt Oct 25, 2020
ccfec1f
Add emphasis for clarity
mikemitchell574 Oct 25, 2020
980f487
Update article.md
plakxj Oct 27, 2020
0682ae7
Delete excess semicolon in 1.9.1 (Class basic syntax)
vsemozhetbyt Oct 27, 2020
9bf1489
Clarify task code place in 1.9.1 (Class basic syntax)
vsemozhetbyt Oct 27, 2020
9a35678
Add missing semicolons in 1.9.2 (Class inheritance)
vsemozhetbyt Oct 27, 2020
7aa2867
Include "object" in MDN link
mikemitchell574 Oct 28, 2020
98d1dc9
modify typo
Youngjin-KimY Oct 29, 2020
972c7ab
Fix possibly outdated note in 1.9.6 (instanceof)
vsemozhetbyt Oct 29, 2020
dc415a6
Merge pull request #2245 from vsemozhetbyt/patch-13
iliakan Oct 29, 2020
075e041
Merge pull request #2243 from Youngjin-KimY/patch-1
iliakan Oct 29, 2020
d1f4466
Merge pull request #2241 from mikemitchell574/patch-6
iliakan Oct 29, 2020
2a55b5b
Merge pull request #2230 from Herrera-pgoat/patch-1
iliakan Oct 29, 2020
0c760be
Update task.md
iliakan Oct 29, 2020
ca17a69
Merge pull request #2231 from Dewke/dewke-minor-fix
iliakan Oct 29, 2020
6a3835a
Merge pull request #2233 from mikemitchell574/patch-1
iliakan Oct 29, 2020
0da8037
Merge pull request #2234 from mikemitchell574/patch-3
iliakan Oct 29, 2020
4379770
Merge pull request #2235 from vsemozhetbyt/patch-9
iliakan Oct 29, 2020
879cfa0
Merge pull request #2236 from mikemitchell574/patch-4
iliakan Oct 29, 2020
1f2987d
Merge pull request #2237 from plakxj/patch-1
iliakan Oct 29, 2020
a6f101c
Merge pull request #2238 from vsemozhetbyt/patch-10
iliakan Oct 29, 2020
4741494
Merge pull request #2239 from vsemozhetbyt/patch-11
iliakan Oct 29, 2020
8c39566
Merge pull request #2240 from vsemozhetbyt/patch-12
iliakan Oct 29, 2020
f2078b1
Update article.md
iliakan Oct 29, 2020
9a6a9fb
Update article.md
iliakan Oct 31, 2020
0e0f4e3
Update article.md
iliakan Nov 1, 2020
010bde1
Update article.md
iliakan Nov 1, 2020
dccca58
Update article.md
iliakan Nov 1, 2020
375ddfc
merging all conflicts
iliakan Nov 2, 2020
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
2 changes: 1 addition & 1 deletion 1-js/03-code-quality/02-coding-style/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Berikut contoh file `.eslintrc`:
},
"rules": {
"no-console": 0,
"indent": ["warning", 2]
"indent": 2
}
}
```
Expand Down
5 changes: 5 additions & 0 deletions 1-js/03-code-quality/06-polyfills/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ Sebenarnya, ada dua bagian dari Babel:

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.

<<<<<<< HEAD
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.
=======
New language features may include not only syntax constructs, but also built-in functions.
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.
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d

Polifyll yang sering digunakan:

Expand Down
4 changes: 4 additions & 0 deletions 1-js/04-object-basics/03-garbage-collection/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ Sederhananya, sebuah nilai yang "terjangkau" adalah mereka yang masih dapat diak

2. Nilai lainnya dianggap terjangkau jika dapat dijangkau dari sebuah _root_ melalui sebuah rujukkan atau rantai rujukkan.

<<<<<<< HEAD
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.
=======
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.
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d

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.

Expand Down
64 changes: 51 additions & 13 deletions 1-js/04-object-basics/07-optional-chaining/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@ The optional chaining `?.` is a safe way to access nested object properties, eve

Jika kamu baru saja membaca tutorial dan belajar Javascript, mungkin masalahnya belum ketemu, tapi itu sudah biasa.

<<<<<<< HEAD
<<<<<<< HEAD
Contoh, beberapa dari pengguna kita punya alamat, tapi beberapa tidak memberikannya. Lalu kita tidak bisa dengan mudah menggunakan `user.address.street`:

```js run
let user = {}; // penggunanya tidak memiliki alamat
=======
As an example, consider objects for user data. Most of our users have addresses in `user.address` property, with the street `user.address.street`, but some did not provide them.
=======
As an example, let's say we have `user` objects that hold the information about our users.
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d

Most of our users have addresses in `user.address` property, with the street `user.address.street`, but some did not provide them.

In such case, when we attempt to get `user.address.street`, we may get an error:
In such case, when we attempt to get `user.address.street`, and the user happens to be without an address, we get an error:

```js run
let user = {}; // a user without "address" property
Expand All @@ -31,6 +37,7 @@ let user = {}; // a user without "address" property
alert(user.address.street); // Error!
```

<<<<<<< HEAD
<<<<<<< HEAD
Atau, didalam pengembangan, kita ingin untuk mendapatkan informasi tentang sebuah elemen didalam halaman, tapi elemennya tidak ada:

Expand All @@ -44,27 +51,32 @@ Sebelum `?.` muncul, operator `&&` digunakan untuk berurusan dengan hal itu.
Contoh:
=======
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").
=======
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.

In many practical cases we'd prefer to get `undefined` instead of an error here (meaning "no street").
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d

...And another example. In the web development, we may need the information about an element on the page. The element is returned by `document.querySelector('.elem')`, and the catch is again - that it sometimes doesn't exist:
...And another example. In the web development, we can get an object that corresponds to a web page element using a special method call, such as `document.querySelector('.elem')`, and it returns `null` when there's no such element.

```js run
// the result of the call document.querySelector('.elem') may be an object or null
// document.querySelector('.elem') is null if there's no element
let html = document.querySelector('.elem').innerHTML; // error if it's null
```

Once again, we may want to avoid the error in such case.
Once again, if the element doesn't exist, we'll get an error accessing `.innerHTML` of `null`. And in 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.

How can we do this?

The obvious solution would be to check the value using `if` or the conditional operator `?`, before accessing it, like this:
The obvious solution would be to check the value using `if` or the conditional operator `?`, before accessing its property, like this:

```js
let user = {};

alert(user.address ? user.address.street : undefined);
```

...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.
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.

E.g. let's try getting `user.address.street.name`.

Expand All @@ -76,10 +88,14 @@ let user = {}; // user has no address
alert(user.address ? user.address.street ? user.address.street.name : null : null);
```

That looks awful.
That's just awful, one may even have problems understanding such code.

<<<<<<< HEAD
Before the optional chaining `?.` was added to the language, people used the `&&` operator for such cases:
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
=======
Don't even care to, as there's a better way to write it, using the `&&` operator:
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d

```js run
let user = {}; // pengguna tidak memiliki alamat
Expand All @@ -92,20 +108,35 @@ Dan juga selutuh path ke propertinya memastikan seluruh komponen ada, tapi terla
=======
AND'ing the whole path to the property ensures that all components exist (if not, the evaluation stops), but also isn't ideal.

As you can see, the property names are still duplicated in the code. E.g. in the code above, `user.address` appears three times.
As you can see, property names are still duplicated in the code. E.g. in the code above, `user.address` appears three times.

<<<<<<< HEAD
And now, finally, the optional chaining comes to the rescue!
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
=======
That's why the optional chaining `?.` was added to the language. To solve this problem once and for all!
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d

## Rantai opsional

<<<<<<< HEAD
Rantai opsional `?.` menghentikan evaluasi dan mengembalikan `undefined` jika bagian sebelum `?.` adalah `undefined` atau `null`.
=======
The optional chaining `?.` stops the evaluation if the part before `?.` is `undefined` or `null` and returns that part.
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d

**Selanjutnya di artikel ini, untuk meringkas, kita akan bilang bahwa sesuatu "ada" jika itu bukan `null` dan bukan `undefined`.**

<<<<<<< HEAD
<<<<<<< HEAD
Ini ada cara teraman untuk mengakses `user.address.street`:
=======
=======
In other words, `value?.prop`:
- is the same as `value.prop` if `value` exists,
- otherwise (when `value` is `undefined/null`) it returns that `value`.

>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d
Here's the safe way to access `user.address.street` using `?.`:
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d

Expand All @@ -132,6 +163,7 @@ alert( user?.address.street ); // undefined

Perhatikan: sintaks `?.` membuat nilai opsional sebelumnya, tapi tidak setelahnya.

<<<<<<< HEAD
<<<<<<< HEAD
Didalam contoh diatas, `user?.` membolehkan hanya `user` untuk `null/undefined`.
=======
Expand All @@ -142,6 +174,9 @@ Disisi lain, jika `user` ada, lalu itu harus memiliki properti `user.address`, s

```warn header="Jangan terlalu berlebihan menggunakan rantai opsional"
Kita harus menggunakan `?.` hanya dimana sesuatu itu tidak apa-apa bila tidak ada.
=======
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 `?.`.
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d

<<<<<<< HEAD
Contoh, jika berdasarkan logika koding kita objek `user` harus ada, tapi `address` bersifat opsional, lalu `user.address?.street` akan lebih baik.
Expand Down Expand Up @@ -210,17 +245,20 @@ Contoh, `?.()` digunakan untuk memanggil fungsi yang mungkin saja tidak ada.
Di kode dibawah, beberapa user mungkin memiliki method `admin`, dan beberapa tidak:

```js run
let user1 = {
let userAdmin = {
admin() {
alert("I am admin");
}
}
};

let userGuest = {};

let user2 = {};
*!*
userAdmin.admin?.(); // I am admin
*/!*

*!*
user1.admin?.(); // I am admin
user2.admin?.();
userGuest.admin?.(); // nothing (no such method)
*/!*
```

Expand Down
4 changes: 4 additions & 0 deletions 1-js/05-data-types/02-number/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,11 @@ Beberapa contoh:
alert( Math.pow(2, 10) ); // 2 in power 10 = 1024
```

<<<<<<< HEAD
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).
=======
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).
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d

## Kesimpulan

Expand Down
6 changes: 6 additions & 0 deletions 1-js/05-data-types/08-weakmap-weakset/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ let array = [ john ];
john = null; // tulis ulang referensinya

*!*
<<<<<<< HEAD
// john disimpan didalam array, jadi itu tidak dibuang
// kita bisa mendapatkannya sebagai array[0]
=======
// the object previously referenced by john is stored inside the array
// therefore it won't be garbage-collected
// we can get it as array[0]
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d
*/!*
```

Expand Down
9 changes: 9 additions & 0 deletions 1-js/06-advanced-functions/04-var/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ function sayHi() {
}

sayHi();
<<<<<<< HEAD
alert(phrase); // Error: frasa tidak terdefinisi (periksa Developer Console)
=======
alert(phrase); // Error: phrase is not defined
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d
```

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.
Expand Down Expand Up @@ -267,8 +271,13 @@ Dalam semua kasus diatas kami mendeklarasikan sebuah Ekspresi fungsi dan menjala

Ada dua perbedaan utama dari `var` dibandingkan dengan `let/const`;

<<<<<<< HEAD
1. `var` variabel tidak memiliki ruang lingkup blok, mereka terlihat minimum pada tingkat fungsi.
2. Deklarasi `var` diproses saat fungsi dimulai (skrip dimulai untuk global).
=======
1. `var` variables have no block scope, their visibility is scoped to current function, or global, if declared outside function.
2. `var` declarations are processed at function start (script start for globals).
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d

Ada satu perbedaan kecil terkait objek global, yang akan kita bahas pada bab selanjutnya.

Expand Down
10 changes: 10 additions & 0 deletions 1-js/06-advanced-functions/05-global-object/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ Objek global menyediakan variabel dan fungsi yang bisa didapatkan dimana saja. S

Di dalam browser ia dinamakan `window`, untuk Node.js `global`, untuk lingkungan lainnya ia mungkin mempunyai nama lain.

<<<<<<< HEAD
<<<<<<< HEAD
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.
=======
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.
>>>>>>> f830bc5d9454d85829e011d914f215eb5896579a
=======
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.
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d

Kita akan memakai `window` disini, dengan anggapan bahwa lingkungan kita adalah browser. Jika script kamu mungkin digunakan di lingkungan lain, lebih baik menggunakan `globalThis`.

Expand All @@ -29,7 +33,13 @@ var gVar = 5;
alert(window.gVar); // 5 (menjadi properti objek global)
```

<<<<<<< HEAD
Mohon jangan bergantung dengan itu! Perilaku ini ada untuk alasan kompatibilitas. Script modern menggunakan [JavaScript modules](info:modules) dimana hal-hal tersebut tidak terjadi.
=======
The same effect have function declarations (statements with `function` keyword in the main code flow, not function expressions).

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.
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d

Jika kita menggunakan `let`, hal tersebut tidak akan terjadi:

Expand Down
4 changes: 4 additions & 0 deletions 1-js/06-advanced-functions/06-function-object/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@ Jika fungsinya di deklarasikan sebagai ekspresi fungsi (tidak didalam alur kode

Juga, fungsi mungkin memiliki properti tambahan. Beberapa librari Javascript yang cukup terkenal banyak menggunakan fitur ini.

<<<<<<< HEAD
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.
=======
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.
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d


Jadi, sebuah fungsi bisa melakukan hal-hal yang berguna dengan dirinya-sendiri dan juga membawa setumpuk fungsionalitas didalam propertinya sendiri.
4 changes: 4 additions & 0 deletions 1-js/06-advanced-functions/07-new-function/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ Bagaimana jika itu bisa mengakses variabel luar?

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.

<<<<<<< HEAD
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.
=======
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.
>>>>>>> dccca58f268ad6d5a6f2160613a8ea3c5cd53a2d

Jadi jika `new Function` mempunyai akses ke variabel luar, itu tidak akan bisa menemukan `userName` yang telah dinamai ulang.

Expand Down
Loading