The getPos function works out the left and top coordinates of the element.
Because an element can be positioned inside of other elements, the while loop starts from the element and loops through all of its parent elements, adding up the offsets of all of those parents, so that you end up with a complete value for the left offset and the top offset.
Because in the particular test that you did, the object that you are getting the position for isn’t nested within another similarly positioned object.
In other words, your object was already relative to 0,0.
When it’s an absolutely position object relative to a differently positioned element, that is where you would see the difference.