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
Vijay Shekh’s Post
More Relevant Posts
-
💥 JavaScript: Where Logic Goes to Die 🤯 Think you understand JavaScript? These mind-bending quirks might change your mind… ⚡ Ever wondered: 👉 Why 9999999999999999 becomes 10000000000000000? 👉 Why 1 < 2 < 3 is true, but 3 > 2 > 1 is false? 👉 Why [] == false is true but [] === false is false? 🧠 Welcome to the world of: ✔️ Type Coercion ✔️ Floating Point Precision ✔️ Weird Comparisons ✔️ Truthy vs Falsy Values 💡 For example (from page 9): 0.1 + 0.2 === 0.3 → ❌ false Because JavaScript uses floating-point math, resulting in 0.30000000000000004 😂 And the classic: 'b' + 'a' + + 'a' + 'a' → “banana” (sort of 😅) 🚀 These aren’t bugs — they’re how JavaScript actually works! 📌 If you're a developer, mastering these quirks will save you from real-world bugs. 💬 Which one shocked you the most? #JavaScript #WebDevelopment #Coding #JS #Frontend #Programming #Developers #CodingLife
To view or add a comment, sign in
-
🚀✨ Today's JavaScript Practice: Strengthening My Fundamentals! ✨🚀 ✨I dedicated some time today to revise and practice core JavaScript concepts. Here's a quick summary of what I worked on 👇 🔹 Primitive Datatypes Created and printed variables using different primitive types like string, number, boolean, undefined, and null. 🔹 Type Conversion Practiced converting a string to a number and vice versa using Number() and String(). 🔹 Objects Stored a person's details using an object and printed the data. 🔹 Even or Odd Checker Built a program to check whether a number is even or odd using multiple approaches. 🔹 Grade Calculator Developed a program using if-else and switch statements to calculate grades based on marks and display results accordingly. 💡 Key Learnings: Strengthened my understanding of variables and datatypes Improved logic building with conditionals and loops Practiced real-time input handling and validation Gained confidence in writing small JavaScript programs Consistency is the key to mastering programming 💪 ✨ #JavaScript #WebDevelopment #Coding #FrontendDevelopment #LearnToCode #Programming ✨
To view or add a comment, sign in
-
🚀 JavaScript Practice: Improving Logic with Real Examples 💡 🚀Today I focused on strengthening my core JavaScript skills by working on two small but powerful problems.🚀 1. Character Frequency Counting 💬I explored how to count how many times each character appears in a string like "racecar". This helped me understand how objects can be used to store and update values dynamically. I also learned how to transform that data into a clean, readable format.💬 📌 Key learning: 🔹 Using objects to track frequency 🔹 Converting data into a structured format 🔹 Building clean output instead of messy strings 2. Array Pair Formatting Next, I worked on converting an array into a custom pair format like [1:2, 3:4, 5:6]. This improved my understanding of looping with steps and grouping elements logically. 📌 Key learning: Iterating through arrays in steps Grouping elements into pairs Understanding the difference between actual data structures and formatted output 🔥 Overall Takeaways ✔ Improved problem-solving approach ✔ Better understanding of objects and arrays ✔ Learned how to format output cleanly and efficiently #JavaScript #CodingPractice #FrontendDevelopment #ProblemSolving #LearningJourney
To view or add a comment, sign in
-
-
🚀 Day 8 of My JavaScript Learning Journey Today I learned about Strings in JavaScript and explored various built-in methods to manipulate text. 📌 What I learned: • A String is a sequence of characters used to store text data • Strings are immutable (cannot be changed directly) • It is a primitive data type • String operations always return a new string ⚙️ String methods I practiced: ✔ length ✔ toUpperCase() / toLowerCase() ✔ trim() ✔ slice() / substring() ✔ replace() ✔ includes() ✔ indexOf() ✔ split() ✔ concat() 💡 I also practiced template literals: Hello ${name} → makes string formatting easier and cleaner. Understanding strings is very important because text handling is used in almost every application. Step by step, I’m improving my JavaScript fundamentals and coding skills. 💻✨ #JavaScript #WebDevelopment #FrontendDevelopment #CodingJourney #LearningInPublic #DeveloperJourney #ProgrammingBasics
To view or add a comment, sign in
-
-
🚀 Mastering JavaScript Array Methods – A Game Changer for Developers! • 🔥 JavaScript array methods are powerful tools that make your code cleaner, shorter, and more readable. • 💡 Instead of writing complex loops, methods like "map()", "filter()", and "reduce()" help you handle data efficiently. • ⚡ These methods are essential for modern development, especially in React and backend logic. 💻 Must-Know Array Methods: • ✅ "map()" – Transform each element in an array • ✅ "filter()" – Extract elements based on conditions • ✅ "reduce()" – Combine values into a single result • ✅ "forEach()" – Execute a function for each element • ✅ "find()" – Get the first matching element 🎯 Why You Should Learn Them: • 🚀 Improves code performance and readability • 🧠 Enhances problem-solving skills • 💼 Highly valued in interviews and real-world projects Start practicing today and level up your JavaScript skills! 💪 Source :- Respected owner ✨ Learn more from w3schools.com ✨ #JavaScript #WebDevelopment #Coding #100DaysOfCode #Frontend
To view or add a comment, sign in
-
🚀 Day 3/30 – JavaScript Challenge (LeetCode #2704: To Be Or Not To Be) Today’s problem was all about building a custom testing utility function using JavaScript — something developers actually use in real-world scenarios! 💡 🔍 What I Learned: How to create a function that returns an object with methods Deep understanding of closures and how values persist Implementing conditional checks with proper error handling Writing clean and reusable code for validation 🧠 Key Concept: I created an expect function that helps compare values using: ✔️ toBe() → checks strict equality (===) ✔️ notToBe() → checks inequality (!==) ⚡ Why it matters? This is similar to how testing frameworks (like Jest) work internally. Understanding this builds strong fundamentals in writing robust and testable code. 💻 Code Highlight: Clean use of closures + returning methods = powerful pattern in JavaScript!
To view or add a comment, sign in
-
-
📘 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐌𝐨𝐝𝐮𝐥𝐞 (𝐁𝐚𝐬𝐢𝐜) 𝐒𝐞𝐜𝐭𝐢𝐨𝐧 1: 𝐁𝐚𝐬𝐢𝐜 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭 (𝐓𝐡𝐞 𝐟𝐮𝐧𝐝𝐚𝐦𝐞𝐧𝐭𝐚𝐥𝐬 𝐨𝐟 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭) 1. What is JavaScript? 2. If you want to use JavaScript in your code editor, what do you need to run? 3. How to see JavaScript output? 4. What is WWW? 5. Who created JavaScript? 6.Describe something Before without JavaScript and After using JavaScript in website? 7. How many types of programming languages can we use? 8.Which type of programming language is JavaScript? 9. What is an interpreted / JIT language? 10. What is a compiled language / What is compiled? 11. Difference between compiled vs interpreted language? 12. What is JavaScript Engine or V8 Engine? 13. What are JavaScript comments? 14. What is immutable and mutable? 15. What is primitive and non-primitive? 🎯 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐐𝐮𝐞𝐬𝐭𝐢𝐨𝐧𝐬 (𝐄𝐱𝐭𝐫𝐚) 1. Why is JavaScript called a single-threaded language? 2. What is event loop in JavaScript? 3. What is JIT (Just-In-Time) compilation? 4. Why JavaScript is so popular in web development? 5. Does JavaScript only run in browsers? #DotNet #AspNetCore #MVC #FullStack #SoftwareEngineering #ProgrammingTips #DeveloperLife #LearnToCode #JavaScript #JS #JavaScriptTips #JSLearning #FrontendDevelopment #WebDevelopment #CodingTips #CodeManagement #DevTools
To view or add a comment, sign in
-
-
"If you’re not using "map", "filter", and "reduce" in JavaScript… you're probably writing more code than needed." 😅 These 3 array methods can level up your code instantly 👇 🔹 map() 👉 Transforms each element of an array 👉 Returns a new array 💻 Example: const nums = [1, 2, 3]; const doubled = nums.map(n => n * 2); // [2, 4, 6] 🔹 filter() 👉 Filters elements based on a condition 👉 Returns a new array 💻 Example: const nums = [1, 2, 3, 4]; const even = nums.filter(n => n % 2 === 0); // [2, 4] 🔹 reduce() 👉 Reduces array to a single value 👉 Very powerful (but often misunderstood) 💻 Example: const nums = [1, 2, 3, 4]; const sum = nums.reduce((acc, curr) => acc + curr, 0); // 10 🚀 Pro Tip: Use "map" for transformation, "filter" for selection, and "reduce" for everything else. 💬 Which one do you use the most in your projects? #javascript #webdevelopment #mern #coding #developers
To view or add a comment, sign in
-
Have you ever wondered why functions in JavaScript can remember their outer variables? That's the magic of closures! They allow a function to access variables from its outer lexical scope, even when the function is executed outside that scope. ────────────────────────────── Understanding Closures and Lexical Scope in JavaScript Dive into the fascinating world of closures and lexical scope in JavaScript with me! #javascript #closures #lexicalscope #programming #webdevelopment ────────────────────────────── Key Rules • A closure is created every time a function is declared. • Closures can help maintain private state in your applications. • Be mindful of memory leaks; closures can keep references to variables longer than necessary. 💡 Try This function outerFunction() { let outerVariable = 'I am outside!'; return function innerFunction() { console.log(outerVariable); }; } const innerFunc = outerFunction(); innerFunc(); // Logs: I am outside! ❓ Quick Quiz Q: What does a closure allow a function to do? A: Access variables from its outer lexical scope. 🔑 Key Takeaway Embrace closures to enhance your JavaScript skills and keep your code organized! ────────────────────────────── Small JavaScript bugs keep escaping to production and breaking critical user flows. Debugging inconsistent runtime behavior steals time from feature delivery.
To view or add a comment, sign in
-
One small word in JavaScript causes a lot of confusion: undefined. Many developers encounter it but don’t fully understand why it appears. In my latest article, I break it down in a practical way: • What undefined actually means • Common scenarios where it shows up • Mistakes developers often make • How to avoid it in real projects This is especially useful if you're learning JavaScript or improving your debugging skills. 🔗 Read the full article: https://lnkd.in/gaGDuAHp Curious — what was the most confusing JavaScript concept for you when you started? #JavaScript #WebDevelopment #FrontendDevelopment #Programming #Coding #SoftwareDevelopment #Debugging #LearnJavaScript
To view or add a comment, sign in
More from this author
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
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?