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
Check the resulting flat array (using `JSON.stringify` to omit computed properties):
137
135
138
136
```js
139
-
console.log(JSON.stringify(leaves.value));
137
+
console.log(JSON.stringify(nodes.value));
140
138
```
141
139
142
140
The result is a flat array containing all objects. Keep in mind that each object has computed properties added: `branch`, `index`, `next`, `parent`, `prev`, and `siblings`
@@ -196,7 +194,7 @@ The result is a flat array containing all objects. Keep in mind that each object
196
194
Now let's try to find the object named "1.2.6":
197
195
198
196
```js
199
-
console.log(JSON.stringify(arrLeaves.find(({ name }) => name ==="1.2.6")));
197
+
console.log(JSON.stringify(nodes.value.find(({ name }) => name ==="1.2.6")));
200
198
```
201
199
202
200
Output:
@@ -205,10 +203,10 @@ Output:
205
203
{ "id": 6, "name": "1.2.6" }
206
204
```
207
205
208
-
If the ID is known, you can use `objLeaves`:
206
+
If the ID is known, you can use `nodesMap`:
209
207
210
208
```js
211
-
console.log(JSON.stringify(objLeaves[6]));
209
+
console.log(JSON.stringify(nodesMap.value[6]));
212
210
```
213
211
214
212
Output:
@@ -221,7 +219,7 @@ Now let's try using the computed properties. Suppose we need to find the parent
221
219
222
220
```js
223
221
console.log(
224
-
JSON.stringify(arrLeaves.find(({ name }) => name ==="1.2.6").parent),
222
+
JSON.stringify(nodes.value.find(({ name }) => name ==="1.2.6").parent),
225
223
);
226
224
```
227
225
@@ -242,7 +240,7 @@ Now let's add the object `{ id: 10, name: "1.2.10" }` to the tree after the obje
242
240
243
241
```js
244
242
// Find the object named "1.2.6"
245
-
constcurObject=arrLeaves.find(({ name }) => name ==="1.2.6");
243
+
constcurObject=nodes.value.find(({ name }) => name ==="1.2.6");
0 commit comments