If you want to have logic working in all places, you write an environment dependent wrapper and use that wrapper. Normalizing to a decent range (resolution - number of significant digits - desired 'accuracy') is always a good approach. And, if you have the issue to only be able to deal with integers 1 up to 4 bytes - pos only or neg and positive - convert (scale and offset) to desired range (always knowing how to properly interpret the 'new' value).
Yep, a wrapper is a great idea, especially in the asynchronous way JS works; I'm just about 6weeks into JavaScript and 4-5days into Espruino... and let's say it's quite different when compared to C++, Python.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
If you want to have logic working in all places, you write an environment dependent wrapper and use that wrapper. Normalizing to a decent range (resolution - number of significant digits - desired 'accuracy') is always a good approach. And, if you have the issue to only be able to deal with integers 1 up to 4 bytes - pos only or neg and positive - convert (scale and offset) to desired range (always knowing how to properly interpret the 'new' value).