var outMsgId = parseInt(context.getVariable(“out_Msg_Id”), 10) + 1;
The above statement is returning Float value. I tried Math utility and other parseInt methods. It is not working. Any Idea ?
Please share your ideas ASAP.
var outMsgId = parseInt(context.getVariable(“out_Msg_Id”), 10) + 1;
The above statement is returning Float value. I tried Math utility and other parseInt methods. It is not working. Any Idea ?
Please share your ideas ASAP.
This is a common question. In JavaScript, numbers are floating point values. Always.
If you want to get a representation of a number that looks like an integer, you can use the .toFixed() method. Like this:
$ jrunscript
nashorn> var msgId = "7";
nashorn> var nextMsgId = (parseInt(msgId, 10) +1);
nashorn> nextMsgId
8.0
nashorn> nextMsgId = (parseInt(msgId, 10) +1).toFixed(0);
8
nashorn> exit(0)