Skip to content

Commit cda9228

Browse files
committed
translations of all task.md and solution.md in Object methods, 'this' are done according to #1 (comment)
1 parent b826555 commit cda9228

File tree

9 files changed

+51
-52
lines changed

9 files changed

+51
-52
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
**Error**!
22

3-
Try it:
3+
Coba ini:
44

55
```js run
66
let user = {
@@ -11,19 +11,19 @@ let user = {
1111
(user.go)() // error!
1212
```
1313

14-
The error message in most browsers does not give us much of a clue about what went wrong.
14+
Pesan error pada kebanyakan peramban tidak memberitahukan kita cukup petunjuk tentang hal apa yang salah.
1515

16-
**The error appears because a semicolon is missing after `user = {...}`.**
16+
**Error muncul karena tidak adanya sebuah titik koma setelah `user = {...}`.**
1717

18-
JavaScript does not auto-insert a semicolon before a bracket `(user.go)()`, so it reads the code like:
18+
JavaScript tidak secara otomatis menyisipkan sebuah tanda titik koma setelah tanda kurung kurawa `(user.go)()`, jadi JavaScript membaca kode seperti ini:
1919

2020
```js no-beautify
2121
let user = { go:... }(user.go)()
2222
```
2323

24-
Then we can also see that such a joint expression is syntactically a call of the object `{ go: ... }` as a function with the argument `(user.go)`. And that also happens on the same line with `let user`, so the `user` object has not yet even been defined, hence the error.
24+
Lalu kita juga bisa melihat bahwa ekspresi gabungan semacam itu adalah sebuah panggilan objek `{ go: ... }` secara sintaks yang juga sebagai sebuah fungsi dengan argumen `(user.go)`. Dan hal tersebut juga terjadi pada baris yang sama dengan `let user`, jadi objek `user` belum didefinisikan, oleh karena itu terjadi error.
2525

26-
If we insert the semicolon, all is fine:
26+
Jika kita menyisipkan tanda titik koma, semuanya akan baik-baik saja:
2727

2828
```js run
2929
let user = {
@@ -34,4 +34,4 @@ let user = {
3434
(user.go)() // John
3535
```
3636

37-
Please note that brackets around `(user.go)` do nothing here. Usually they setup the order of operations, but here the dot `.` works first anyway, so there's no effect. Only the semicolon thing matters.
37+
Tolong ingat bahwa tanda kurung kurawa yang merangkap `(user.go)` tidak melakukan apapun di sini. Biasanya Biasanya tanda kurung kurawa mengatur urutan operasi, tapi di sini tanda titik-lah (`.`) yang berjalan terlebih dulu, jadi tidak ada pengaruh apapun. Hanya tanda titik koma yang berpengaruh.

1-js/04-object-basics/04-object-methods/2-check-syntax/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 2
22

33
---
44

5-
# Syntax check
5+
# Cek sintaks
66

7-
What is the result of this code?
7+
Apa hasil dari kode berikut ini?
88

99

1010
```js no-beautify
@@ -16,4 +16,4 @@ let user = {
1616
(user.go)()
1717
```
1818

19-
P.S. There's a pitfall :)
19+
P.S. Ada jebakannya :)
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11

2-
Here's the explanations.
2+
Ini dia penjelasannya.
33

4-
1. That's a regular object method call.
4+
1. Itu adalah sebuah panggilan metode objek biasa.
55

6-
2. The same, brackets do not change the order of operations here, the dot is first anyway.
6+
2. Sama halnya, tanda kurung kurawa tidak merubah urutan operasi di sini, lagi pula tanda titik lah yang pertama di urutan operasi.
77

8-
3. Here we have a more complex call `(expression).method()`. The call works as if it were split into two lines:
8+
3. Di sini kita memiliki sebuah panggilan yang lebih kompleks lagi yakni `(expression).method()`. Pagnggilan tersebut bekerja sebagaimana jika panggilan itu dipisah menjadi dua baris kode:
99

1010
```js no-beautify
11-
f = obj.go; // calculate the expression
12-
f(); // call what we have
11+
f = obj.go; // mengkalkulasi ekspresi
12+
f(); // memanggil apa yang kita punya
1313
```
1414

15-
Here `f()` is executed as a function, without `this`.
15+
Di sini `f()` dieksekusi sebagai sebuah fungsi, tanpa `this`.
1616

17-
4. The similar thing as `(3)`, to the left of the dot `.` we have an expression.
17+
4. Hal serupa pada panggilan `(3)`, di sebelah kiri tanda titik `.` kita memiliki sebuah ekspresi.
1818

19-
To explain the behavior of `(3)` and `(4)` we need to recall that property accessors (dot or square brackets) return a value of the Reference Type.
20-
21-
Any operation on it except a method call (like assignment `=` or `||`) turns it into an ordinary value, which does not carry the information allowing to set `this`.
19+
Untuk menjelaskan perilaku panggilan `(3)` dan `(4)` kita perlu memanggil ulang, yang mana properti pengakses (tanda titik atau tanda kurung siku) mengembalikan sebuah nilai dari tipe referensi (*Reference Type*).
2220

21+
Operasi apapun kecuali sebuah panggilan metode (seperti penugasan `=` atau `||`) membuat membuat ekspresi tersebut menjadi sebuah nilai biasa, yang tidak membawa informasi yang memungkinkan untuk menentukan `this`.

1-js/04-object-basics/04-object-methods/3-why-this/task.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 3
22

33
---
44

5-
# Explain the value of "this"
5+
# Jelaskan nilai dari "this"
66

7-
In the code below we intend to call `obj.go()` method 4 times in a row.
7+
Dalam kode di bawah ini kita bermaksud untuk memanggil metode `obj.go()` sebanyak 4 kali sekaligus.
88

9-
But calls `(1)` and `(2)` works differently from `(3)` and `(4)`. Why?
9+
Tapi panggilan `(1)` dan `(2)` bekerja berbeda dibanding dengan `(3)` dan `(4)`. Mengapa demikian?
1010

1111
```js run no-beautify
1212
let obj, method;
@@ -15,9 +15,9 @@ obj = {
1515
go: function() { alert(this); }
1616
};
1717

18-
obj.go(); // (1) [object Object]
18+
obj.go(); // (1) [objek Object]
1919

20-
(obj.go)(); // (2) [object Object]
20+
(obj.go)(); // (2) [objek Object]
2121

2222
(method = obj.go)(); // (3) undefined
2323

1-js/04-object-basics/04-object-methods/4-object-property-this/solution.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
**Answer: an error.**
1+
**Jawaban: error.**
22

3-
Try it:
3+
Coba ini:
44
```js run
55
function makeUser() {
66
return {
@@ -11,18 +11,18 @@ function makeUser() {
1111

1212
let user = makeUser();
1313

14-
alert( user.ref.name ); // Error: Cannot read property 'name' of undefined
14+
alert( user.ref.name ); // Error: Tidak bisa membaca properti 'name' dari undefined
1515
```
1616

17-
That's because rules that set `this` do not look at object definition. Only the moment of call matters.
17+
Hal itu karena aturan-aturan yang mengatur `this` tidak melihat definisi objek. Yang penting hanya momen saat panggilan terjadi.
1818

19-
Here the value of `this` inside `makeUser()` is `undefined`, because it is called as a function, not as a method with "dot" syntax.
19+
Di sini nilai dari `this` dalam `makeUser()` adalah `undefined`, karena dipanggil sebagai sebuah fungsi, tidak sebagai sebuah metode dengan sintaks "tanda titik".
2020

21-
The value of `this` is one for the whole function, code blocks and object literals do not affect it.
21+
Nilai `this` adalah satu untuk keseluruhan fungsi, blok kode serta penulisan objek tidak mempengaruhi nilai tersebut.
2222

23-
So `ref: this` actually takes current `this` of the function.
23+
Jadi `ref: this` sebenarnya mengambil `this` yang sekarang dari fungsi tersebut.
2424

25-
Here's the opposite case:
25+
Berikut ini contoh kasus kebalikannya:
2626

2727
```js run
2828
function makeUser() {
@@ -41,4 +41,4 @@ let user = makeUser();
4141
alert( user.ref().name ); // John
4242
```
4343

44-
Now it works, because `user.ref()` is a method. And the value of `this` is set to the object before dot `.`.
44+
Kini kode itu berfugsi, karena `user.ref()` adalah sebuah metode. Dan nilai dari `this` ditentukan ke objek sebelum tanda titik `.`.

1-js/04-object-basics/04-object-methods/4-object-property-this/task.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 5
22

33
---
44

5-
# Using "this" in object literal
5+
# Menggunakan "this" dalam penulisan objek
66

7-
Here the function `makeUser` returns an object.
7+
Berikut ini adalah fungsi `makeUser` yang mengembalikan sebuah objek.
88

9-
What is the result of accessing its `ref`? Why?
9+
Apa hasil dari mengakses `ref`? Mengapa demikian?
1010

1111
```js
1212
function makeUser() {
@@ -18,6 +18,6 @@ function makeUser() {
1818

1919
let user = makeUser();
2020

21-
alert( user.ref.name ); // What's the result?
21+
alert( user.ref.name ); // Apa hasilnya?
2222
```
2323

1-js/04-object-basics/04-object-methods/7-calculator/task.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ importance: 5
22

33
---
44

5-
# Create a calculator
5+
# Membuat sebuah kalkulator
66

7-
Create an object `calculator` with three methods:
7+
Buatlah sebuah objek `calculator` dengan tiga metode:
88

9-
- `read()` prompts for two values and saves them as object properties.
10-
- `sum()` returns the sum of saved values.
11-
- `mul()` multiplies saved values and returns the result.
9+
- `read()` mendorong kedua nilai dan menyimpan nilai-nilai tersebut sebagai properti objek.
10+
- `sum()` mengembalikan jumlah dari nilai-nilai yang disimpan.
11+
- `mul()` mengalikan nilai-nilai yang disimpan dan mengembalikan hasilnya.
1212

1313
```js
1414
let calculator = {

1-js/04-object-basics/04-object-methods/8-chain-calls/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The solution is to return the object itself from every call.
1+
Solusinya adalah untuk mengembalikan objek itu sendiri dari setiap panggilan.
22

33
```js run demo
44
let ladder = {
@@ -26,7 +26,7 @@ let ladder = {
2626
ladder.up().up().down().up().down().showStep(); // 1
2727
```
2828

29-
We also can write a single call per line. For long chains it's more readable:
29+
Kita juga bisa menuliskan sebuah panggilan di setiap baris. Untuk rantai kode yang panjang jadi lebih mudah dibaca seperti ini:
3030

3131
```js
3232
ladder

1-js/04-object-basics/04-object-methods/8-chain-calls/task.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 2
22

33
---
44

5-
# Chaining
5+
# *Chaining* (merantaikan)
66

7-
There's a `ladder` object that allows to go up and down:
7+
Ada sebuah objek layaknya tangga (`ladder`) yang dapat naik dan turun:
88

99
```js
1010
let ladder = {
@@ -15,13 +15,13 @@ let ladder = {
1515
down() {
1616
this.step--;
1717
},
18-
showStep: function() { // shows the current step
18+
showStep: function() { // menunjukkan langkah yang sekarang
1919
alert( this.step );
2020
}
2121
};
2222
```
2323

24-
Now, if we need to make several calls in sequence, can do it like this:
24+
Kini, jika kita perlu untuk membuat beberapa panggilan secara berurutan, bisa dilakukan dengan cara seperti ini:
2525

2626
```js
2727
ladder.up();
@@ -30,10 +30,10 @@ ladder.down();
3030
ladder.showStep(); // 1
3131
```
3232

33-
Modify the code of `up`, `down` and `showStep` to make the calls chainable, like this:
33+
Modifikasi kode `up`, `down` dan `showStep` untuk membuat panggilan-panggilan tersebut dapat dirantaikan satu sama lain, seperti ini:
3434

3535
```js
3636
ladder.up().up().down().showStep(); // 1
3737
```
3838

39-
Such approach is widely used across JavaScript libraries.
39+
Pendekatan demikian digunakan secara luas di banyak *library* JavaScript.

0 commit comments

Comments
 (0)