Today I published a new blog on how "this" works in JavaScript. One thing that confuses many beginners is that "this" is not fixed. Its value depends on who is calling the function. In the article I break down: What "this" refers to in different environments "this" inside normal functions vs inside objects How function borrowing works The difference between call(), apply(), and bind() https://lnkd.in/dEKGEZGw I also used simple examples (including a fun Ferrari F1 analogy) to make the concept easier to understand. Chai Aur Code Hitesh Choudhary Piyush Garg Akash Kadlag Jay Kadlag #javascript #webdevelopment #coding #learninpublic #chaicode
Understanding JavaScript's Dynamic 'this' Concept
More Relevant Posts
-
Solved Majority Element and implemented Bubble Sort from scratch today — in both C and JavaScript. 💪 Majority Element → used an object as a frequency counter. One loop to count, one loop to find the max. Clean O(n) solution. Bubble Sort → no built-in methods, pure logic. Compare adjacent elements, swap if needed, repeat n-1 times. Each pass bubbles the largest element to its correct position. The real lesson? Understanding why it works matters more than just getting it to work. If you're on a DSA grind too, let's connect! 👇 #DSA #LeetCode #C #JavaScript #BubbleSort #100DaysOfCode
To view or add a comment, sign in
-
-
Built an efficient JavaScript solution to find the maximum and second maximum elements in an array using a single pass approach, optimizing performance with O(n) time complexity and constant space. #JavaScript #DSA #Coding #LeetCode #WebDevelopment
To view or add a comment, sign in
-
-
If you think semicolons don’t matter in JavaScript…? Click “more” before you scroll ... Skipping semicolons feels harmless… 👀 Until this happens 👇 const arr = [1, 2, 3] (function () { console.log("Hello 👋") })() 👉 Error: arr is not a function 😳 👉 Why? JavaScript thinks you're calling the array as a function Because there’s no semicolon before the IIFE 👉 Fix: const arr = [1, 2, 3]; 👉 Small symbol… big problem 😬 This is due to Automatic Semicolon Insertion (ASI) ⚡ Follow for more simple dev concepts 🚀 #JavaScript #Developers #WebDevelopment #Coding #Debugging #Relatable
To view or add a comment, sign in
-
-
Built a little browser game over the weekend using just vanilla JavaScript. No frameworks, no libraries — one HTML file. Move your cursor to destroy enemies, survive boss waves, grab power-ups. Runs at 60fps with particle effects and procedural audio. Sometimes the best way to sharpen your skills is to build something fun. Try it: https://lnkd.in/gQGEcv-v #JavaScript #WebDev #CreativeCoding
To view or add a comment, sign in
-
-
JavaScript Number Guessing Game I just built a Number Guessing Game in JavaScript! 🎯 💡 Features: Random number generation (1-100) User input validation Hints: “Too high” / “Too low” Counts attempts Exit anytime This project helped me practice loops, conditionals, variables, and working with user input in JavaScript. Try it yourself! Code runs in the browser console or Node.js with prompt-sync. 💻 Skills practiced: JavaScript fundamentals, logic, problem-solving #JavaScript #Coding #WebDevelopment #LearningByDoing
To view or add a comment, sign in
-
-
💡 Learning Something New in JavaScript Today! Today I learned about the padStart() method in JavaScript. It’s a simple but very useful string method that helps format values by adding characters to the beginning of a string until it reaches a desired length. Example: "5".padStart(3, "0") // Output: "005" This is especially helpful when formatting: Dates and times (e.g., 09, 07) Serial numbers or IDs Counters and timers Small concepts like these make code cleaner and more readable. Excited to keep exploring more JavaScript features every day! #JavaScript #WebDevelopment #CodingJourney #FrontendDevelopment
To view or add a comment, sign in
-
Javascript concept: var vs let vs const I used var everywhere when I started learning JavaScript… Everything worked… until it didn’t. var a = 10; let b = 20; const c = 30; Then I learned: var ignores block scope ❌ let respects it ✅ const prevents reassignment 🔒 💡 Now my rule: → Use const by default → Use let only when needed #JavaScript #WebDevelopment #Frontend #Coding
To view or add a comment, sign in
-
😵 This one line in JavaScript can trick you! let a = 10; let b = a++; console.log("Addition", a + b, "a = ", a, "b = ", b) At first glance, you might expect both values to be the same… right? 🤔 But JavaScript has its own way of handling this. 👉 Why does b get 10 instead of 11? 👉 When exactly does the increment happen? 👉 And how is this different from ++a? This small concept can lead to big bugs if you misunderstand it. I’ve broken it down clearly in my latest video 🎥 Watch it once — you’ll never get confused again. #JavaScript #Frontend #WebDevelopment #Coding #LearnJavaScript
To view or add a comment, sign in
-
Async JavaScript is easier to understand when you stop thinking about “parallel code.” JavaScript still runs on a single main thread. What makes it feel non-blocking is the event loop, callback queue, and browser/runtime APIs working together. That is why setTimeout, fetch, and promises do not pause everything else. The big idea: async code gets scheduled first, then runs when the stack is ready. This infographic breaks that flow into the exact pieces that matter. Which JavaScript topic should I simplify next? #JavaScript #AsyncJavaScript #EventLoop #WebDevelopment #FrontendDevelopment #Programming #Promises #AsyncAwait
To view or add a comment, sign in
-
-
Day 8 of “Js in bits series – (typeof) Key things covered in the article: 🔹 How typeof helps identify different JavaScript datatypes 🔹 What typeof returns for primitives like number, string, boolean, bigint, undefined, and symbol 🔹 Why typeof null returns "object" (a long-standing JavaScript quirk) 🔹 Practical examples of using typeof in real code #javascript #webdevelopment #frontend #softwareengineering #coding #learning
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