Merge pull request #1543 from lumosmind/patch-12

linked list must end with 'null'
This commit is contained in:
Ilya Kantor 2019-10-29 23:37:46 +03:00 committed by GitHub
commit bb3f9aaa40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -459,6 +459,7 @@ let list = { value: 1 };
list.next = { value: 2 }; list.next = { value: 2 };
list.next.next = { value: 3 }; list.next.next = { value: 3 };
list.next.next.next = { value: 4 }; list.next.next.next = { value: 4 };
list.next.next.next.next = null;
``` ```
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. 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.