The JS library is shipped in version 3.1.2 when installing the JS Scripting add-on, I guess previousStateTimestamp was added in a later version.
Please note that previousStateTimestamp is likely to be removed in favour of previousState returning an object including state and timestamp - see this issue report.
There is almost never a case where you should be messing with epoch anyway. It’s far better to keep the ZonedDateTimes and Duration to work with date times.
This is true in both Rules DSL and JS Scripting.
Note, the current version in main depends on some changes in OH core. I wouldn’t expect it to necessarily work on older OH 3.x versions.
Don’t. There’s no reason to. If you are comparing two timestamps, compare them directly using isBefore() and isAfter(). If you need the difference between two timestamps, use time.Duration.between(time1, time2).