🚀 Day 18 of My JavaScript Journey – call(), apply(), and bind() Today I learned how to control the value of this using three powerful methods: 👉 call() 👉 apply() 👉 bind() Understanding these helped me connect everything I learned about the this keyword. 💡 What I Understood Sometimes we want a function to use a different object as its context. Instead of rewriting the function, JavaScript allows us to control what this refers to. That’s where these methods come in: 🔹 call() – Invokes a function immediately and sets this manually. 🔹 apply() – Similar to call(), but arguments are passed as an array. 🔹 bind() – Returns a new function with this permanently set (does not execute immediately). 🧠 Why This Is Important These methods are commonly used in: Function borrowing Event handling setTimeout scenarios React (especially class components) Interview coding questions Learning this made me realize how flexible and powerful JavaScript functions really are. Each concept is building on the previous one Execution Context → Call Stack → Closures → this → call/apply/bind. Slowly strengthening my fundamentals every single day 💪 #JavaScript #FrontendDeveloper #WebDevelopment #LearningInPublic #100DaysOfCode #WomenInTech
Mastering JavaScript's call(), apply(), and bind() for Flexible Functions
More Relevant Posts
-
New Blog Published: Handling Multiple Promises in JavaScript (Promise.all(), Promise.any(), Promise.allSettled()) Ever wondered how JavaScript handles multiple asynchronous operations at the same time? In real-world applications we often run many async tasks together like fetching APIs, loading resources, or uploading files. Choosing the right Promise method can make your code much cleaner and more efficient. In this blog, I break down: Why JavaScript needs Promises for asynchronous tasks When to use Promise.all() When Promise.any() is the right choice When Promise.allSettled() becomes useful Real-life analogies and practical examples for better understanding Written in a simple way for developers who want to understand when and why to use these methods in real projects and interviews. 🔗 Read here: https://lnkd.in/gbXvwWdJ Thanks to Hitesh Choudhary sir and Piyush Garg sir, for providing this type of knowledge of web browser internal. #JavaScript #WebDevelopment #AsyncProgramming #Promises #ChaiCode
To view or add a comment, sign in
-
🚀 Day 21 of My JavaScript Journey – Async/Await Today I learned how to write asynchronous JavaScript in a cleaner and more readable way using: 👉 Async / Await After understanding Promises, this felt like the missing piece. 💡 What I Understood Async/Await is built on top of Promises, but it makes asynchronous code look like synchronous code — which makes it much easier to read and maintain. 🔹 async makes a function return a Promise 🔹 await pauses execution until the Promise resolves 🔹 try...catch helps handle errors cleanly 🧠 Why This Is Powerful Instead of chaining multiple .then() calls, Async/Await allows writing structured, clean logic — especially when working with APIs. This is extremely useful for: Fetching data from APIs Handling backend responses Working with authentication Real-world React applications 🔥 Biggest Realization Understanding Async/Await made the Event Loop and Promises much clearer. Now I can confidently understand how: Call Stack → Web APIs → Microtasks → Event Loop → Async code execution all connect together. Every day I’m strengthening my JavaScript fundamentals step by step. Consistency and practice over shortcuts 💪 On to Day 22 🚀 #JavaScript #FrontendDeveloper #AsyncAwait #WebDevelopment #LearningInPublic #100DaysOfCode
To view or add a comment, sign in
-
JavaScript Comments. 🚀 Most beginners ignore this simple JavaScript feature… but it can save HOURS of confusion. It’s called JavaScript Comments. Comments are notes inside your code that JavaScript ignores, but developers read. They help explain what the code is doing and why it exists. When you start working in teams, comments become extremely valuable. Here are the basics 👇 • Single-line comment Use // to write a quick note on one line. • Multi-line comment Use /* ... */ when your explanation needs multiple lines. • Explain complex logic If a piece of code is tricky, leave a comment so others understand it. • Use comments for debugging Temporarily comment out code to test something. • Keep comments meaningful Avoid obvious comments like // add two numbers. Good comments make your code clean, readable, and team-friendly. #JavaScript #WebDevelopment #FrontendDevelopment #ProgrammingTips #CodingForBeginners #LearnToCode #JavaScriptDeveloper #SoftwareDevelopment #TechEducation #CleanCode
To view or add a comment, sign in
-
-
A few days ago while I was working on some small JavaScript projects, someone saw my screen and said something like: "Why are you building these tiny things? You should be building something bigger." I didn’t really argue or explain much in that moment. But the truth is simple: these "small" projects are intentional. It’s not as if I don’t know how to build bigger things, fetch APIs, or write more complex JavaScript applications. These small projects are deliberate — they’re about focusing on fundamentals, testing my understanding, and making sure my foundation is solid. This choice is intentional, not a limitation. Right now, I’m revisiting JavaScript fundamentals to see whether my understanding is still solid and to further strengthen the foundation in my brain. Building these mini projects gives me the chance to refresh key concepts like logic, loops, and conditions, while watching them come together to create something tangible and meaningful. Every solid structure starts with a strong base, and for me, that’s what these projects are about. Still learning. Still building. One step at a time. #JavaScript #LearningInPublic #WebDevelopment #BuildInPublic
To view or add a comment, sign in
-
Most developers learn JavaScript… but struggle when it comes to arrays in real projects. And the truth is — Arrays are used everywhere. So I created a JavaScript Array CheatSheet that makes everything simple and practical. Inside this guide: ⚡ Add elements → push() / unshift() ⚡ Remove elements → pop() / shift() ⚡ Check existence → includes() ⚡ Find index → indexOf() ⚡ Iterate arrays → forEach() / map() ⚡ Find elements → find() Each concept is explained with: ✔ Clean code examples ✔ Real outputs ✔ Easy-to-understand logic Perfect for: ✅ Beginners learning JavaScript ✅ Frontend developers ✅ Interview preparation ✅ Quick revision before coding 💡 If you master arrays, you unlock 80% of JavaScript logic building. 📌 Save this post — you’ll need it again. 💬 Comment “JS” and I’ll share the full cheat sheet. Follow for more JavaScript tips, roadmaps, and developer content. #JavaScript #FrontendDevelopment #WebDevelopment #JS #CodingTips #LearnJavaScript #Programming #Developers #SoftwareEngineering #CodingLife #DeveloperCommunity #SurajSingh
To view or add a comment, sign in
-
🚀 Day 19 of My JavaScript Journey – The Event Loop Today I learned how JavaScript actually handles asynchronous code behind the scenes. 👉 The Event Loop This concept completely changed how I understand setTimeout, Promises, and async behavior. 💡 What I Learned JavaScript is single-threaded — it can do one thing at a time. But then how does it handle: setTimeout API calls Promises Async/Await That’s where the Event Loop comes in. 🧠 Key Concepts I Understood 🔹 Call Stack – Executes synchronous code 🔹 Web APIs – Handle async operations (like setTimeout, fetch) 🔹 Callback Queue – Stores completed async callbacks 🔹 Microtask Queue – Stores Promise callbacks 🔹 Event Loop – Moves tasks to the Call Stack when it’s empty 🔥 Important Realization Promises (microtasks) are executed before setTimeout (macrotasks). Understanding this helped me predict output order in tricky interview questions. 🎯 Why This Matters The Event Loop is the foundation of: Async JavaScript API handling Performance optimization Debugging tricky timing issues The more I learn, the more I realize that mastering JavaScript fundamentals is the key to becoming a strong frontend developer. Consistency > Speed 💪 On to Day 20 🚀 #JavaScript #FrontendDeveloper #EventLoop #WebDevelopment #LearningInPublic #100DaysOfCode
To view or add a comment, sign in
-
Understanding the JavaScript Event Loop is a game changer for writing efficient asynchronous code. Many developers use setTimeout and Promise daily — but fewer truly understand what happens behind the scenes. Here’s a quick breakdown 👇 🔹 JavaScript is single-threaded 🔹 Synchronous code runs first (Call Stack) 🔹 Then all Microtasks execute (Promises, queueMicrotask) 🔹 Then one Macrotask runs (setTimeout, setInterval, DOM events) 🔹 The loop repeats 📌 Execution Priority: Synchronous → Microtasks → Macrotasks Example: console.log(1); setTimeout(() => console.log(2), 0); Promise.resolve().then(() => console.log(3)); console.log(4); ✅ Output: 1 → 4 → 3 → 2 Understanding this helps in: ✔ Debugging async issues ✔ Optimizing performance ✔ Writing better React applications ✔ Cracking frontend interviews I’ve created a simple infographic to visually explain the entire Event Loop process. If you're preparing for JavaScript or React interviews, mastering this concept is essential. 💬 Now Your Turn 👇 What will be the output of this code? console.log("A"); setTimeout(() => console.log("B"), 0); Promise.resolve().then(() => { console.log("C"); }); console.log("D"); 👉 Learn more with w3schools.com Follow for daily React and JavaScript 👉 MOHAMMAD KAIF #JavaScript #FrontendDevelopment #ReactJS #WebDevelopment #EventLoop #CodingInterview
To view or add a comment, sign in
-
-
💻 Day 85 & 86 — Mastering JavaScript Functions Over the last two days, I explored one of the most important concepts in JavaScript — Functions. Functions are the backbone of JavaScript, and understanding different types of functions helped me understand how JS programs are structured, optimized, and executed. 🎯 What I Learned / Practiced 🔹 Function Basics — Learned the basic structure of functions and how parameters & arguments work; understood the difference between void functions (perform a task but don't return a value) and non-void functions (return a value) 🔹 Functional Hoisting — Discovered that function declarations are hoisted, allowing them to be called before they are defined; this is not possible with function expressions or arrow functions 🔹 Function Expressions — Practiced storing functions inside variables using named and anonymous function expressions 🔹 Arrow Functions (ES6) — Learned the cleaner syntax for writing functions; they reduce code length, do not bind their own this, and are ideal for callbacks 🔹 IIFE (Immediately Invoked Function Expressions) — Explored functions that execute immediately, useful for private variables and avoiding global scope pollution 🔹 Rest Parameters — Practiced accepting multiple dynamic values, helpful in cases like summation and merging arrays 🔹 Default Parameters — Learned how to predefine parameter values to avoid errors like undefined calculations 🔹 Closures & Lexical Scoping — Studied how closures occur when a function remembers variables from its outer function even after execution; helps build data privacy and real-world features like authentication 🌱 Key Takeaways These two days helped me deeply understand how JavaScript handles memory, how functions behave internally, and how scope, execution context, and closures work. Understanding closures strengthened my foundation of JavaScript's execution model. 🔗 Links GitHub:https://lnkd.in/gdGwMimd Live Demo (Vercel):https://lnkd.in/g-urNhBy 🙏 Thank you for the continuous guidance and support Codegnan | Uppugundla Sairam | Saketh Kallepu | Ambica Kiranmayee Bellamkonda #Day85 #Day86 #FullStackDevelopment #JavaScript #Functions #Closures #LearningJourney
To view or add a comment, sign in
-
🚀 Day 6 of My JavaScript Journey Today was all about mastering Strings & Date Object in JavaScript — and honestly, it made me realize how powerful these basics really are 🔥 Here’s what I learned 👇 📌 Strings in JavaScript Different ways to create strings ("", '', and backticks ` `) Why backticks (template literals) are modern & super useful 💡 Finding string length using .length Accessing characters using index 📌 Important Concept Strings are immutable → original value can’t be changed ⚠️ 📌 String Methods Convert text: .toUpperCase() .toLowerCase() Search inside strings: .includes(), .indexOf() Extract parts: .slice() (supports negative index 🔥) .substring() Modify strings: .replace() .trim() Convert string to array: .split() 📌 Concatenation Combine strings using + Mixing numbers with strings → automatic type conversion 🤯 📌 Date Object (Real Game Changer 🕒) Getting current date & time Understanding UTC vs Local Time Formatting date (ISO & local formats) Extracting parts like year, month, day Creating custom dates 📌 Advanced Concepts Date.now() → gives milliseconds since Epoch (Jan 1, 1970) ⏳ Importance of UTC & Epoch Time in real-world apps Browser automatically converts UTC → Local Time 🌍 💡 Big Learning: Even basic things like strings & dates have deep concepts that are used in real-world applications like chat apps, logs, scheduling systems, etc. Consistency is the key 🔑 Day by day, getting closer to becoming a better developer 💻🔥 #JavaScript #WebDevelopment #MERNStack #CodingJourney #Day6 #Learning #Developers
To view or add a comment, sign in
-
-
Today's JavaScript Practice Tasks As part of my Frontend Developer learning journey, I practiced the following JavaScript tasks today: 1. Created a Promise function getUserData() that resolves after 2 seconds and handles errors using catch(). 2. Wrote a function to divide two numbers and reject if the denominator is 0. 3. Implemented reverseWords(sentence) to reverse each word in a string using split(), map(), and join(). 4. Created removeDuplicates (arr) to return a new array without duplicate values using filter(). 5. Built sumEvenNumbers(arr) to filter even numbers and calculate their sum. Learning JavaScript step by step and improving my problem-solving skills every day. #JavaScript #Frontend Developer #WebDevelopment #Learning Journey #CodingPractice
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