This is slower in v8 than having a `typeof` in each if, because v8 can't do an optimization (apparently).