Math.trunc is not a function

I’m trying to use Math.trunc in a transformation, I’ve tried both inline and as a script. But the openhab.log file is reporting it’s an unknown function:

Executing the JS-transformation failed: An error occurred while executing script. TypeError: Math.trunc is not a function in <eval> at line number

I’m using openHAB 3.4.0.RC1, and as far as I can tell, it’s supposed to be ECMAScript 2021+, which supports Math.trunc. It’s not the end of the world, as I can just use Math.round for this, which it doesn’t complain about.

How do I find out what functions I can use in openHAB? Is there something else I need to do to get this to work?

AFAIK, the JS Transformation in 3.x uses ECMAScript 5.1.

It will be upgraded to ECMAScript 2021 in openhab 4.0 if you install the jsscripting addon.