This may be a strange question as I don't have a specific example in mind. I am in the process of trying to learn JavaScript and while reviewing some material I began wondering if it is possible to increment/decrement by less than one (1).
In other words if there were a situation where you needed to increment a variable by something other that "1". E.g. incrementing the variable i by 0.5 as opposed to 1, for (var i = 0, i < 10.5, i++/2) {...
As I said, I don't have a specific example or reason for needing to do this. I am just curious if:
- It is legal within JavaScript?
- Is this something that would possibly come up in a real scenario?
- If so, is this the correct way of doing it, or is there a different/better way to increment/decrement by a fractional number?
Thank you in advance for any response!
Not the same question as the issue experienced in How to increment number by 0.01 in javascript using a loop?