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
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.
3
3
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.
5
5
6
6
```js run
7
7
*!*
8
8
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
11
11
returnObject.keys(this).join();
12
12
}
13
13
}
@@ -17,15 +17,15 @@ let dictionary = Object.create(null, {
17
17
dictionary.apple="Apple";
18
18
dictionary.__proto__="test";
19
19
20
-
// apple and __proto__ is in the loop
20
+
// apple dan __proto berada didalam perulangan
21
21
for(let key in dictionary) {
22
-
alert(key); // "apple", then "__proto__"
22
+
alert(key); // "apple", lalu "__proto__"
23
23
}
24
24
25
-
//comma-separated list of properties by toString
25
+
//properti dari daftar yang dipisahkan dengan koma oleh toString
26
26
alert(dictionary); // "apple,__proto__"
27
27
```
28
28
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.
30
30
31
-
See the the chapter [](info:property-descriptors)for review.
31
+
Lihat bab [](info:property-descriptors)untuk review.
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`.
8
8
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.
10
10
11
-
Here's how it should work:
11
+
Ini adalah contohnya:
12
12
13
13
```js
14
14
let dictionary =Object.create(null);
15
15
16
16
*!*
17
-
//your code to add dictionary.toString method
17
+
//metode yang ditambahkan dictionary.toString
18
18
*/!*
19
19
20
-
//add some data
20
+
//tambahkan beberapa data
21
21
dictionary.apple="Apple";
22
-
dictionary.__proto__="test"; // __proto__ is a regular property key here
22
+
dictionary.__proto__="test"; // __proto__ adalah kunci properti biasa disini
23
23
24
-
//only apple and __proto__ are in the loop
24
+
//hanya apple dan __proto__ yang berada di perulangan
0 commit comments