en.javascript.info/2-ui/1-document/03-dom-navigation/3-navigation-links-which-null/solution.md
Ilya Kantor 7d6d4366a3 minor
2019-05-21 18:05:46 +03:00

593 B

  1. Yes, true. The element elem.lastChild is always the last one, it has no nextSibling.
  2. No, wrong, because elem.children[0] is the first child among elements. But there may exist non-element nodes before it. So previousSibling may be a text node. Also, if there are no children, then trying to access elem.children[0]

Please note: for both cases if there are no children, then there will be an error.

If there are no children, elem.lastChild is null, so we can't access elem.lastChild.nextSibling. And the collection elem.children is empty (like an empty array []).