First of all, you approach may not return what you want.
lastPage = app.activeDocument.pages.length-1;
is only returning the length of pages in the document minus 1. So if you have 12 pages, it will return 11 and not a reference to the last page.
If you want so, you have to ask for :
lastPage = app.activeDocument.pages[-1];
Once said, why don't you have a look in the Indesign object model ?
Page.side (Read Only)
Data Type: PageSideOptions
The side of the binding spine on which to place the page within the spread.
Its index will be odd for even pages, even for odd pages.
You don't even have to check the "last" page; if the document length is odd, the last page is a verso. If the document length is even, the last page is a recto. Of course, this assumes you started with a regular (verso) page.
You should always use the side property.
The index of the page (or documentOffset) is not always a good
right bound documents
spreads with more than (or less than) 2 pages.
Spreads which are set to not shuffle can be either recto or verso.