Skip to content

Commit dea8d86

Browse files
authored
Merge pull request #195 from yoga1234/master
translate
2 parents 5679ab0 + dc4477d commit dea8d86

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

2-
The method can take all enumerable keys using `Object.keys` and output their list.
2+
Pemanggilan metode bisa mengambil semua kunci yang terhitung menggunakan `Object.keys` dan mengeluarkan daftarnya.
33

4-
To make `toString` non-enumerable, let's define it using a property descriptor. The syntax of `Object.create` allows us to provide an object with property descriptors as the second argument.
4+
Untuk membuat `toString` tidak bisa dihitung, kita bisa mendefinisikannya menggunakan deskriptor properti. Sintaks dari `Object.create` membolehkan kita untuk menyediakan sebuah objek dengan deskriptor properti sebagai argumen kedua.
55

66
```js run
77
*!*
88
let dictionary = Object.create(null, {
9-
toString: { // define toString property
10-
value() { // the value is a function
9+
toString: { // definisikan properti tostring
10+
value() { // nilainya adalah fungsi
1111
return Object.keys(this).join();
1212
}
1313
}
@@ -17,15 +17,15 @@ let dictionary = Object.create(null, {
1717
dictionary.apple = "Apple";
1818
dictionary.__proto__ = "test";
1919

20-
// apple and __proto__ is in the loop
20+
// apple dan __proto berada didalam perulangan
2121
for(let key in dictionary) {
22-
alert(key); // "apple", then "__proto__"
22+
alert(key); // "apple", lalu "__proto__"
2323
}
2424

25-
// comma-separated list of properties by toString
25+
// properti dari daftar yang dipisahkan dengan koma oleh toString
2626
alert(dictionary); // "apple,__proto__"
2727
```
2828

29-
When we create a property using a descriptor, its flags are `false` by default. So in the code above, `dictionary.toString` is non-enumerable.
29+
Ketika kita membuat sebuah properti menggunakan deskriptor, tandanya akan menjadi `false` secara bawaan. Jadi kode diatas, `dictionary.toString` tidak bisa dihitung.
3030

31-
See the the chapter [](info:property-descriptors) for review.
31+
Lihat bab [](info:property-descriptors) untuk review.
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
importance: 5
1+
nilai: 5
22

33
---
44

55
# Add toString to the dictionary
66

7-
There's an object `dictionary`, created as `Object.create(null)`, to store any `key/value` pairs.
7+
Terdapat sebuah objek `dictionary`, dibuat sebagai `Object.create(null)`, untuk menyimpan pasangan `key/value`.
88

9-
Add method `dictionary.toString()` into it, that should return a comma-delimited list of keys. Your `toString` should not show up in `for..in` over the object.
9+
Tambahkan metode `dictionary.toString()` kedalamnya, yang harus mengembalikan daftar yang dibatasi dengan koma. `toString` milikmu haruslah tidak tampil didalam `for..in` dalam objeknya.
1010

11-
Here's how it should work:
11+
Ini adalah contohnya:
1212

1313
```js
1414
let dictionary = Object.create(null);
1515

1616
*!*
17-
// your code to add dictionary.toString method
17+
// metode yang ditambahkan dictionary.toString
1818
*/!*
1919

20-
// add some data
20+
// tambahkan beberapa data
2121
dictionary.apple = "Apple";
22-
dictionary.__proto__ = "test"; // __proto__ is a regular property key here
22+
dictionary.__proto__ = "test"; // __proto__ adalah kunci properti biasa disini
2323

24-
// only apple and __proto__ are in the loop
24+
// hanya apple dan __proto__ yang berada di perulangan
2525
for(let key in dictionary) {
26-
alert(key); // "apple", then "__proto__"
26+
alert(key); // "apple", lalu "__proto__"
2727
}
2828

29-
// your toString in action
29+
// toString milikmu
3030
alert(dictionary); // "apple,__proto__"
3131
```

0 commit comments

Comments
 (0)