💡 The Curious Case of NaN in JavaScript Ever tried this in JavaScript? 👇 console.log(typeof NaN); // 🤔 Surprise! The output is "number" 😄 That’s right — NaN (Not-a-Number) is ironically of type number! It represents an invalid numeric operation — like dividing 0 / 0 or parsing Number("abc"). Think of it like this: “NaN is JavaScript’s polite way of saying — I tried to do the math, but it doesn’t make sense!” 😅 #JavaScript #CodingTips #WebDevelopment #FrontEnd #LearnJavaScript #CodeNewbie #TechCommunity #DeveloperLife #ProgrammingHumor
JavaScript NaN: A Polite Error Message
More Relevant Posts
-
JavaScript thing I randomly remembered today 😅 You know how let and const throw an error if you try to use them before declaring? That weird phase has a name — Temporal Dead Zone (TDZ). console.log(a); // ❌ ReferenceError let a = 5; It’s not that a doesn’t exist. It’s there... just not initialized yet. Basically, JS says “I know you declared it, but don’t touch it till I’m ready.” 😂 var doesn’t have this — which is why it caused chaos in old codebases. Crazy part? This all happens before your code even runs. JavaScript is wild sometimes 😅 #JavaScript #WebDevelopment #CodingLife #Frontend
To view or add a comment, sign in
-
-
💻 JavaScript Code Challenges: Level Up Your Skills 💻 Want to truly master JavaScript? Stop memorizing and start practicing with real engine-level challenges: 1️⃣ Scope & Lexical Environment let a = 10; function test() { let a = 20; console.log(a); } test(); // ? console.log(a); // ? 2️⃣ Closures function counter() { let count = 0; return function() { count++; return count; } } const inc = counter(); console.log(inc()); // ? console.log(inc()); // ? 3️⃣ Hoisting & TDZ console.log(x); // ? let x = 5; console.log(y); // ? var y = 10; ✅ Challenge yourself: Predict the output before running the code. Understand why it behaves that way. That’s how you think like the JS engine! #JavaScript #CodingChallenge #Closures #Scope #Hoisting #LexicalScoping #TDZ #DevCommunity #WebDevelopment #ProgrammingTips #CleanCode
To view or add a comment, sign in
-
🚀 JavaScript isn’t just a language — it’s pure magic that runs the web! Let’s do a quick JS challenge 👇 👉 Guess what this code will print: console.log(typeof null); Most people say "null", but surprise — the answer is actually "object" 😲 That’s one of JavaScript’s oldest quirks — a bug that became a feature! It reminds us that no language is perfect, but JavaScript’s flexibility and weirdness are what make it so powerful. 💪 💬 Now your turn: What’s the most confusing or fun JS behavior you’ve encountered? Drop it in the comments — let’s see who can out-weird JavaScript today! ⚡ #JavaScript #Coding #WebDevelopment #ProgrammingHumor #LearnToCode
To view or add a comment, sign in
-
|| Day - 27 || + JavaScript Basics : Cohort 2.0 ✨ Key Learnings of the Day: 1. Explored different console functions such as console.log(), console.error(), and console.table() to debug and display data efficiently. 2. Learned various string operations and how to manipulate text dynamically using JavaScript. + Step 2 in JavaScript for Web Development. >> #HarshVandanaSharma #SheriyansCohort2 #SheriyansCodingSchool #LearningJourney #JS #WebDevelopment #FrontendDesign #CareerGrowth
To view or add a comment, sign in
-
-
💥 JavaScript: The Language That Makes You Say “WHAT?!” 🤯 Look at this for 5 seconds 👇 console.log([] == ![]); // true 😳 Wait… what?! How can an empty array be equal to NOT an empty array? 💀 Welcome to the wild world of JavaScript type coercion 😅 Here’s what’s actually happening: 👉 ![] → becomes false (because arrays are truthy) 👉 So now it’s [] == false 👉 JS tries to be helpful and converts both sides to numbers [] → 0 and false → 0 ✅ 0 == 0 → true BOOM 💥 mind = blown. 🧠 Pro Tip: Always use === instead of == unless you love debugging existential crises 😅 🔥 Your turn — what’s the weirdest JS behavior you’ve ever seen? Drop it below 👇 Let’s confuse the internet together. #JavaScript #Frontend #WebDev #ProgrammingHumor #CodingLife #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Did you know? Node.js is single-threaded for your JavaScript code — but multi-threaded under the hood ⚙️ 🧠 Here’s how it works: JavaScript itself runs on one main thread — the Event Loop. But Node.js uses a C library called libuv, which provides a thread pool for handling heavy I/O tasks like file access, crypto, or DNS lookups. So while your JS code is single-threaded, Node.js quietly spins up multiple native threads to do the heavy lifting in the background 💪 👷♂️ What about Worker Threads? If you ever have CPU-bound tasks (like image processing or data crunching) that block the Event Loop , you can manually create Worker Threads in Node.js to run code in parallel on different threads 🧵 Each worker: Runs its own JS instance (with its own event loop) Can communicate with the main thread via messages Helps you fully utilize multi-core CPUs 🚀 💡 Takeaway: Node.js gives you the best of both worlds: ✅ Simplicity of single-threaded JS ⚡ Power of multi-threaded performance when you need it #Nodejs #JavaScript #BackendDevelopment #AsyncProgramming #libuv #WorkerThreads #WebDevelopment #CodingTips #Performance #EventLoop #letsLearnWithPrateek #Day9
To view or add a comment, sign in
-
#TIL The “You Don’t Need” series is a great reality check for many long-lived JS habits. One of the classics: You don’t need Lodash anymore. Most of its utilities are now built into the language — Array.flatMap, Object.entries, String.replaceAll, and so on. And for teams who still want familiar APIs, there’s a modern alternative: ES Toolkit — smaller, faster, actively maintained, fully typed, and even Lodash-compatible. Resources worth checking: • https://lnkd.in/e_VkCk_Y • https://lnkd.in/e7wCZBQx • https://es-toolkit.dev/ Lodash/Underscore has served us well — but modern JS gives us cleaner, faster, and native ways to get the same job done. #JavaScript #Frontend #WebDevelopment #Performance #Tooling #YouDontNeedSeries
To view or add a comment, sign in
-
Coming from a C++ background, I was used to working with a true multithreaded language, whre multiple functions could wrestle for CPU time. Then I hit JavaScript… and realized it’s single-threaded. Only one function can actually run at a time. which changed how i approach problems. I was working on a small project — basically just making a div move randomly across the screen. Sounds simple, right? But when you give it independent X and Y targets, things get chaotic fast. The movement looks alive, unpredictable, like it’s thinking. That’s when I learned about requestAnimationFrame(). At first, I thought it just “runs things continuously.” Nope. It schedules them — about 60 times a second. You’re not looping; you’re politely asking the browser to let your code run again at the next frame and if you don’t structure it right, like putting requestAnimationFrame() inside your function but not calling it again outside, your function just fires once and quits. Feels small, but understanding this changed how I think about JavaScript, not as a slower , but as a completely different beast that plays by its own rules. #javascript #frontend
To view or add a comment, sign in
-
-
Recently I was preparing for JavaScript and I stumbled upon a simple concept — but most people don’t know the key differences between var and let. Here’s a quick example: ` for (var i = 0; i < 3; i++) { setTimeout(() => console.log(i), 1000); } // Output: 3 3 3 ` ` for (let i = 0; i < 3; i++) { setTimeout(() => console.log(i), 1000); } // Output: 0 1 2 ` Key differences: Scope: var is function-scoped, let is block-scoped. Hoisting & Temporal Dead Zone: var is hoisted and initialized with undefined, let is hoisted but not initialized — accessing it before declaration throws a ReferenceError. Understanding these small details can save you from tricky bugs, especially in loops and async code! #JavaScript #JS #WebDevelopment #FrontendDevelopment #Coding #LearnToCode #DeveloperTips #TechCommunity #CodeSnippet #Programming ## I’d appreciate it if you could share a few more examples to help me understand.
To view or add a comment, sign in
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