Home

Search IconIcon to open search

JS quirks

# All numbers are floating-point

So 9007199254740992 + 1 is 9007199254740992. You probably should use BigInt for this.

# null is an object. Kind of.

typeof returns "object" for the null type. This is a known issue in JavaScript since its first release.

# Division by zero is not UB

It’s either Infinity or -Infinity. Also there’s 0 and -0. So 1/0 is Infinity and 1/-0 is -Infinity. Division by zero is only undefined for ±0/±0 and ±∞/±∞.

# self vs window

self is a more portable way of using a global object. In browser self defaults to window.