Number() trims whitespace and then requires the whole remaining string to be a valid numeric literal. An empty or whitespace-only string trims to "" which Number treats as 0. But "12px" contains trailing non-numeric characters, so Number returns NaN. Unlike parseInt, which would stop at the first invalid char and return 12.