Skip to content

Commit 95495bd

Browse files
authored
linked list must end with 'null'
We need to put 'null' to end of linked list. otherwise wen we want to get last item in the linked list, it will be undefined. And this situation inconsistent with object literal definition of linked list above.
1 parent d5195b5 commit 95495bd

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

1-js/06-advanced-functions/01-recursion/article.md

+1
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ let list = { value: 1 };
459459
list.next = { value: 2 };
460460
list.next.next = { value: 3 };
461461
list.next.next.next = { value: 4 };
462+
list.next.next.next.next = null;
462463
```
463464
464465
Here we can even more clearer see that there are multiple objects, each one has the `value` and `next` pointing to the neighbour. The `list` variable is the first object in the chain, so following `next` pointers from it we can reach any element.

0 commit comments

Comments
 (0)