470 B
470 B
- Yes, true. The element
elem.lastChild
is always the last one, it has nonextSibling
, so if there are children, then yes. - No, wrong, because
elem.children[0]
is the first child among elements. But there may be non-element nodes before it. SopreviousSibling
may be a text node.
Please note that for both cases if there are no children, then there will be an error. For instance, if elem.lastChild
is null
, we can't access elem.lastChild.nextSibling
.