0.1 + 0.2 === 0.3 in JavaScript? 🤯 #shorts
Description: Is 0.1 + 0.2 equal to 0.3 in JavaScript? 🤔
Most developers get this wrong!
✅ Answer: false
0.1 + 0.2 = 0.30000000000000004
Why? Computers store numbers in binary, and 0.1 can't be stored exactly in binary. So a tiny rounding error appears. It's not just JavaScript: Python does it too!
💡 Working with money? Use cents: 10 + 20 === 30 ✅
Quiz #2 answer: a printed [1, 2, 3, 4], because b = a points to the same array.
Comment your answer and follow for JS Quiz #4! 🚀
#javascript #coding #programming #webdevelopment #jsquiz #learnjavascript #howtodev Close description
Most developers get this wrong!
✅ Answer: false
0.1 + 0.2 = 0.30000000000000004
Why? Computers store numbers in binary, and 0.1 can't be stored exactly in binary. So a tiny rounding error appears. It's not just JavaScript: Python does it too!
💡 Working with money? Use cents: 10 + 20 === 30 ✅
Quiz #2 answer: a printed [1, 2, 3, 4], because b = a points to the same array.
Comment your answer and follow for JS Quiz #4! 🚀
#javascript #coding #programming #webdevelopment #jsquiz #learnjavascript #howtodev Close description
