You’ve already set length to be arr.length. In the next line you say while (arr.length–), which would work out to be (arr.arr.length–), which doesn’t exist. So the first block works and the second does not.
The error that the second block generates is because it tries to set an array’s length to -1 when it gets to the last execution evaluation, and that is an invalid array length.
As an aside, don’t play with an array’s length this way. It’s difficult to read and understand what you’re trying to do, as most people would assume an array’s length to be a read-only property. (Which was my assumption too).