I've been looking at a lot of math in Javascript recently, and have seen lots of lines that end with "|0" at the end of a line. For instance, I was looking at the asm.js output of the Coinhive mining code, and see things like this all over the place:
k = (d[a + 45 >> 0] | 0) << 1;
l = c[4768 + (k << 2) >> 2] | 0;
k = c[4768 + ((k | 1) << 2) >> 2] | 0;
m = (d[a + 54 >> 0] | 0) << 1;
You can see that the various operations all end with "|0". These are operations on typed array values, so that may be why. It's just that I seem to vaguely recall seeing an explanation once before, but can't find any sort of answer at the moment.
Does anyone know why this needs to be done in Javascript?