Skip to content

Commit 79f9bd3

Browse files
authored
Merge pull request #191 from yoga1234/master
translate
2 parents 5e89bf3 + 5a0312b commit 79f9bd3

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11

2-
Answers:
2+
Jawaban:
33

44
1. `true`.
55

6-
The assignment to `Rabbit.prototype` sets up `[[Prototype]]` for new objects, but it does not affect the existing ones.
6+
Memasukan ke `Rabbit.prototype` menyetel `[[Prototype]]` untuk objek baru, tapi itu tidak memberikan efek pada yang sudah ada.
77

88
2. `false`.
99

10-
Objects are assigned by reference. The object from `Rabbit.prototype` is not duplicated, it's still a single object referenced both by `Rabbit.prototype` and by the `[[Prototype]]` of `rabbit`.
10+
Objek yang dimasukan dengan menggunakan referensi. Objek dari `Rabbit.prototype` bukanlah di duplikasi, itu masih tetap objek tunggal yang direferensikan dari `Rabbit.prototype` dan dari `[[Prototype]]` dari `rabbit`.
1111

12-
So when we change its content through one reference, it is visible through the other one.
12+
Jadi ketika kita mengubah kontennya melalui satu referensi, itu masih terlihat melalui yang lainnya.
1313

1414
3. `true`.
1515

16-
All `delete` operations are applied directly to the object. Here `delete rabbit.eats` tries to remove `eats` property from `rabbit`, but it doesn't have it. So the operation won't have any effect.
16+
Semua operasi `delete` diterapkan langsung ke objeknya. Disini `delete rabbit.eats` mencoba untuk menghapus properti `eats` dari `rabbit`, tapi itu tidak memilikinya. Jadi operasinya tidak akan menghasilkan efek apapun.
1717

1818
4. `undefined`.
1919

20-
The property `eats` is deleted from the prototype, it doesn't exist any more.
20+
Properti `eats` dihapus dari *prototype*, itu tidak akan ada lagi.

1-js/08-prototypes/02-function-prototype/1-changing-prototype/task.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
importance: 5
1+
nilai: 5
22

33
---
44

5-
# Changing "prototype"
5+
# Merubah "prototype"
66

7-
In the code below we create `new Rabbit`, and then try to modify its prototype.
7+
Di kode dibawah kita membuat `new Rabbit`, dan mencoba memodifikasi prototypenya.
88

9-
In the start, we have this code:
9+
Pada awalnya kita memiliki kode ini:
1010

1111
```js run
1212
function Rabbit() {}
@@ -20,7 +20,7 @@ alert( rabbit.eats ); // true
2020
```
2121

2222

23-
1. We added one more string (emphasized). What will `alert` show now?
23+
1. Kita menambah satu string (ditekankan). What will `alert` show now?
2424

2525
```js
2626
function Rabbit() {}
@@ -37,7 +37,7 @@ alert( rabbit.eats ); // true
3737
alert( rabbit.eats ); // ?
3838
```
3939

40-
2. ...And if the code is like this (replaced one line)?
40+
2. ...Dan jika kodenya seperti ini (diganti satu baris)?
4141

4242
```js
4343
function Rabbit() {}
@@ -54,7 +54,7 @@ alert( rabbit.eats ); // true
5454
alert( rabbit.eats ); // ?
5555
```
5656

57-
3. And like this (replaced one line)?
57+
3. Dan seperti ini (diganti satu baris)?
5858

5959
```js
6060
function Rabbit() {}
@@ -71,7 +71,7 @@ alert( rabbit.eats ); // true
7171
alert( rabbit.eats ); // ?
7272
```
7373

74-
4. The last variant:
74+
4. varian terakhir:
7575

7676
```js
7777
function Rabbit() {}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
We can use such approach if we are sure that `"constructor"` property has the correct value.
1+
Kita bisa menggunakan pendekatan jika kita yakin properti `"constructor"` memiliki nilai yang benar.
22

3-
For instance, if we don't touch the default `"prototype"`, then this code works for sure:
3+
Contoh, kita tidak ingin menyentuh `"prototype"` bawaan, maka kode ini akan berjalan dengan semestinya:
44

55
```js run
66
function User(name) {
@@ -10,14 +10,14 @@ function User(name) {
1010
let user = new User('John');
1111
let user2 = new user.constructor('Pete');
1212

13-
alert( user2.name ); // Pete (worked!)
13+
alert( user2.name ); // Pete (bekerja!)
1414
```
1515

16-
It worked, because `User.prototype.constructor == User`.
16+
Kode diatas bekerja karena `User.prototype.constructor == User`.
1717

18-
..But if someone, so to speak, overwrites `User.prototype` and forgets to recreate `constructor` to reference `User`, then it would fail.
18+
Tapi jika seseorang, menimpah `User.prototype` dan lupa untuk membuat ulang `constructor` untuk `User`, maka akan membuat kegagalan.
1919

20-
For instance:
20+
Contoh:
2121

2222
```js run
2323
function User(name) {
@@ -33,12 +33,12 @@ let user2 = new user.constructor('Pete');
3333
alert( user2.name ); // undefined
3434
```
3535

36-
Why `user2.name` is `undefined`?
36+
Kenapa `user2.name` menghasilan `undefined`?
3737

38-
Here's how `new user.constructor('Pete')` works:
38+
Ini bagaimana `new user.constructor('Pete')` bekerja:
3939

40-
1. First, it looks for `constructor` in `user`. Nothing.
41-
2. Then it follows the prototype chain. The prototype of `user` is `User.prototype`, and it also has nothing.
42-
3. The value of `User.prototype` is a plain object `{}`, its prototype is `Object.prototype`. And there is `Object.prototype.constructor == Object`. So it is used.
40+
1. Pertama, itu akan mencari `constructor` didalam `user`. Tidak ditemukan.
41+
2. Lalu akan mengukuti rantai *prototype*. *Prototype* dari `user` adalah `User.prototype`, dan itu juga tidak memilikinya.
42+
3. Nilai dari `User.prototype` adalah sebuah objek polos `{}`, prototypenya adalah `Object.prototype`. dan disana terdapat `Object.prototype.constructor == Object`. Jadi itu digunakan.
4343

44-
At the end, we have `let user2 = new Object('Pete')`. The built-in `Object` constructor ignores arguments, it always creates an empty object, similar to `let user2 = {}`, that's what we have in `user2` after all.
44+
Pada akhirnya kita memiliki `let user2 = new Object('Pete')`. Konstruktor `Object` bawaan menghiraukan argumen, itu selalu menciptakan objek kosong, sama seperti `let user2 = {}`, itulah yang kita punya didalam `user2`.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
importance: 5
1+
nilai: 5
22

33
---
44

5-
# Create an object with the same constructor
5+
# Buat sebuah objek dengan konstruktor yang sama
66

7-
Imagine, we have an arbitrary object `obj`, created by a constructor function -- we don't know which one, but we'd like to create a new object using it.
7+
Bayangkan, kita memiliki objek yang berubah-ubah, dibuat dengan menggunakan fungsi konstruktor -- kita tidak tahu yang mana, tapi kita ingin membuat sebuah objek menggunakannya.
88

9-
Can we do it like that?
9+
Bisakah kita melakukannya?
1010

1111
```js
1212
let obj2 = new obj.constructor();
1313
```
1414

15-
Give an example of a constructor function for `obj` which lets such code work right. And an example that makes it work wrong.
15+
Beri sebuah contoh dari menggunakan fungsi konstruktor untuk `obj` yang mana membiarkan kode seperti itu bekerja. Dan sebuah contoh yang mana membuat kodenya menjadi tidak bekerja semestinya.

0 commit comments

Comments
 (0)