The following code returns a function that is stateful. Just try running the output of the factory multiple times. Then re-manufacture the output and then run it again. You'll see that the output is the same, which means it's keeping track of state between runs.
But I'm not quite sure how this is possible... can somebody explain?
function mulberry32(a) {
return function() {
var t = a += 0x6D2B79F5;
t = Math.imul(t ^ t >>> 15, t | 1);
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
return ((t ^ t >>> 14) >>> 0) / 4294967296;
}
}