'Difference between ta.pivotlow and ta.pivotlow used in ta.valuewhen

I'm new to pinescript and have been looking at pivotlow/pivothigh. The part that confuses me is the difference between the two pivot calculations below:

    leftbars = 2
    rightbars = 2

    pivotLow = ta.pivotlow(low, leftbars, rightbars) // Returns the pivotlow value or NaN if not applicable
    recentPivotLow = ta.valuewhen(ta.pivotlow(low, leftbars, rightbars), low, 0) // Returns the most recent pivot low value

When checking the value of pivotLow and recentPivotLow, there's a difference while I would be expecting them to be the same since ta.valuewhen returns the most recent occurrence when '0' is passed along. Would like to understand why there's a difference and where its coming from.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source