In a numbered ordering of the document's nodes, insertBefore() will place newNode at the index held by refNode, and increment refNode's index and all subsequent nodes' indices. This is instead of maintaining refNode's index, placing newNode at refNode's position minus one, and shifting all previous nodes' indices down by one.
The base case of refNode.index = 0 demonstrates why this must be the case, but it is good to know this explicitly, as it affects methods that deal with iteration such as getElementsByTagName().