Why Does JavaScript’s parseInt(0.0000005) Print “5”?

Why does parseInt(0.0000005) in JavaScript print 5? An amazing question!

fatfish
JavaScript in Plain English
3 min readApr 20, 2024

--

Preface

Recently, I have had a strange problem when developing a project, parseInt (0.0000005) === 5 😱. Normally, the output 0 is correct, but why 5? Let’s explore this problem together.

--

--

Hi friends, I am a front-end engineer from Alibaba, let’s code happily together.