Vijay Shekh’s Post

Javascript: NaN ⚠️ JavaScript has a value that literally means “Not a Number”… but it is still a number type! Yes, that confusing value is called NaN. Many beginners get surprised when they see it in their code. Let’s simplify it. NaN stands for Not a Number, and it appears when JavaScript fails to convert something into a valid number. Example situations: • Trying to divide something impossible → 0 / 0 • Converting text into numbers → Number("Hello") • Invalid math operations → Math.sqrt(-1) • Parsing wrong values → parseInt("abc") Important things to remember: • typeof NaN is "number" 🤯 • NaN is not equal to itself (NaN === NaN → false) • Use Number.isNaN() to properly check it • It often appears during data validation bugs Understanding NaN helps you avoid hidden bugs in JavaScript applications. Small concept… but very important for debugging. #JavaScript #WebDevelopment #FrontendDevelopment #LearnToCode #ProgrammingTips #JavaScriptBasics #CodingForBeginners #SoftwareEngineering #DevCommunity #100DaysOfCode

  • No alternative text description for this image

Nice Information, could you please guide me in which scenario to use this NaN while working with web application, I mean in which scenario it fits good?

Like
Reply

To view or add a comment, sign in

Explore content categories