I have a code similar to this:
let requestId = 0;
function newRequest() {
// stuff
return requestId++; // what happens at the limit? I want wrap around.
}
I want requestId, since I want to increment to wrap around to 0 when I get to the maximum value. In C++, this is as easy as this:
auto requestId = std::uint32_t{0};
auto newRequest() -> std::uint32_t {
// stuff
return requestId++; // always defined behaviour, wraps around
}
I just want ++ to always be defined behaviour and wrap around. Is it possible in javascript?