Today, I explored one of the core topics in JavaScript — Operators. Understanding different types of operators like Arithmetic, Comparison, Logical, and Assignment helps in writing efficient and logical code. Every symbol in JavaScript has a purpose, and learning how they work gives more control over program logic and decision-making. Operators in JavaScript: Definition: Operators in JavaScript are special symbols or keywords that are used to perform operations on operands (values or variables). They help in performing various tasks like arithmetic calculations, comparisons, logical decisions, and assignments. Example: let x = 10 + 5; Here, + is an operator, and 10 and 5 are operands. ⚙️ Types of JavaScript Operators 1. Arithmetic Operators Arithmetic operators are used to perform mathematical calculations such as addition, subtraction, multiplication, and division. List of Arithmetic Operators: + (Addition): Adds two operands. - (Subtraction): Subtracts one operand from another. * (Multiplication): Multiplies two operands. / (Division): Divides one operand by another. % (Modulus): Returns the remainder after division. ** (Exponentiation): Raises a number to a power. ++ (Increment): Increases the value of a variable by 1. -- (Decrement): Decreases the value of a variable by 1. 2. Assignment Operators Assignment operators are used to assign values to variables. They can also perform operations and assign the result to the same variable. Examples: = → Assigns a value. += → Adds and assigns. -= → Subtracts and assigns. *= → Multiplies and assigns. /= → Divides and assigns. %= → Finds remainder and assigns. 3. Comparison Operators Comparison operators are used to compare two values. The result of a comparison operation is either true or false. Examples: == → Equal to (compares value only). === → Strict equal to (compares value and type). != → Not equal to. !== → Strict not equal to (value and type). > → Greater than. < → Less than. >= → Greater than or equal to. <= → Less than or equal to. let a = 10; let b = 5; console.log(a + b); // 15 (Addition) console.log(a - b); // 5 (Subtraction) console.log(a * b); // 50 (Multiplication) console.log(a / b); // 2 (Division) console.log(a % b); // 0 (Remainder) console.log(a ** 2); // 100 (Exponentiation) a++; // Increment console.log(a); // 11 b--; // Decrement console.log(b); // 4 let x = 10; x += 5; // x = x + 5 console.log(x); // 15 x -= 3; // x = x - 3 console.log(x); // 12 x *= 2; // x = x * 2 console.log(x); // 24 let a = 10; let b = "10"; console.log(a == b); // true (equal value) console.log(a === b); // false (equal value but different type) console.log(a != b); // false (same value) console.log(a !== b); // true (different type) console.log(a > 5); // true #javascript #webdevelopment #codingjourney #learning
Understanding JavaScript Operators: Arithmetic, Assignment, and Comparison
More Relevant Posts
-
Today I revised some of the most essential JavaScript concepts that appear in real-world development. 1️⃣ Higher-Order Function (HOF) ✅ Question: Create a function that runs another function twice 📝 Code: function runTwice(fn) { fn(); fn(); } runTwice(() => console.log("hello")); 🔍 Short Explanation: A HOF is a function that takes another function as input or returns a function. Helps in reusable logic. 2️⃣ Pure Function 📝 Code: function pure(a, b) { console.log(a + b); } pure(2, 3); pure(2, 3); 🔍 Short Explanation: Always gives the same output for the same input. No side effects. 3️⃣ Impure Function 📝 Code: let global = 0; function imPure(a) { global++; console.log(a + global); } imPure(2); imPure(2); 🔍 Short Explanation: Depends on external data → output changes unexpectedly. 4️⃣ Destructuring in Function Parameters 📝 Code: const obj = { name: "Pratik", age: 21 }; function destructuring({ name, age }) { console.log(name, age); } destructuring(obj); 🔍 Short Explanation: Pulls values directly from objects → cleaner code. 5️⃣ Normal Function vs Arrow Function (this difference) 📝 Code: let objTwo = { name: "Pratik", fnc: function () { console.log(this); }, arrowFnc: () => { console.log(this); } }; objTwo.fnc(); objTwo.arrowFnc(); 🔍 Short Explanation: Normal function → owns its own this Arrow function → uses parent this (lexical) 6️⃣ map(): Square each number 📝 Code: let arr = [1, 2, 3, 4, 5]; let newArr = arr.map(e => e * e); console.log(newArr); 🔍 Short Explanation: Transforms each element → returns a new array. 7️⃣ filter(): Get even numbers 📝 Code: let filtered = arr.filter(e => e % 2 === 0); console.log(filtered); 🔍 Short Explanation: Keeps only the elements that match a condition. 8️⃣ reduce(): Total salary 📝 Code: let salary = [10000, 20000, 30000]; let total = salary.reduce((acc, v) => acc + v, 0); console.log(total); 🔍 Short Explanation: Reduces an array into one final value. 9️⃣ some() & every() 📝 Code: let names = ["pratik", "sun", "om", "krish", "vijay"]; let some = names.some(e => e.length > 3); let every = names.every(e => e.length > 3); console.log(some, every); 🔍 Short Explanation: some() → at least ONE matches every() → ALL must match 🔟 Object.freeze() 📝 Code: const users = { name: "Sunny", age: 21 }; Object.freeze(users); users.age = 22; users.city = "Surat"; delete users.name; console.log(users); 🔍 Short Explanation: No add, no delete, no modify → completely locked. 1️⃣1️⃣ Object.seal() 📝 Code: const test = { subject: "Maths", score: 50 }; Object.seal(test); test.score = 60; test.grade = "A"; delete test.subject; console.log(test); 🔍 Short Explanation: You can modify, but cannot add or delete keys. 1️⃣2️⃣ Optional Chaining (?.) 📝 Code: const user = { name: "Pratik", address: { city: "Surat" } }; console.log(user?.address?.city); 🔍 Short Explanation: Avoids errors when accessing nested properties.
To view or add a comment, sign in
-
Day 18/100 Day 9 of JavaScript Arrow Functions in JavaScript — A Modern & Cleaner Way to Write Functions In modern JavaScript (ES6+), arrow functions provide a shorter and more elegant way to write functions. They make your code concise and improve readability, especially when working with callbacks or array methods like .map(), .filter(), and .reduce(). What is an Arrow Function? An arrow function is simply a compact syntax for defining functions using the => (arrow) symbol. Syntax: const functionName = (parameters) => { // block of code }; It’s equivalent to: function functionName(parameters) { // block of code } Example: Traditional vs Arrow Function Traditional Function: function add(a, b) { return a + b; } console.log(add(5, 3)); // Output: 8 Arrow Function: const add = (a, b) => a + b; console.log(add(5, 3)); // Output: 8 Cleaner and shorter! Key Features of Arrow Functions : No function keyword — Makes your code concise. Implicit return — If the function body has only one statement, the result is automatically returned (no need for return). Lexical this binding — Arrow functions don’t have their own this. They inherit this from the parent scope — making them great for use inside callbacks or class methods. Example: Lexical this function Person() { this.name = "Appalanaidu"; setTimeout(() => { console.log(this.name); // Works perfectly! }, 1000); } new Person(); // Output: Appalanaidu If we had used a regular function inside setTimeout, this would be undefined or refer to the global object — not the instance. Arrow functions solve that issue neatly. Quick Recap Shorter syntax Implicit return Lexical this Great for callbacks Example Use Case: Array Mapping const numbers = [1, 2, 3, 4]; const squares = numbers.map(num => num * num); console.log(squares); // Output: [1, 4, 9, 16] Arrow functions make such one-liners elegant and easy to read! Final Thought Arrow functions are not just syntactic sugar — they’re a modern JavaScript feature that simplifies code and makes your logic cleaner. Once you start using them, you’ll rarely go back to the old way! #10000coders
To view or add a comment, sign in
-
✍️ JavaScript Tip: Optional Chaining (?.) If you’ve ever tried accessing something deep inside an object and got an error like: Cannot read property 'x' of undefined You're not alone 😅 This happens a lot when you're not sure if a value exists. For example, you’re trying to access user.profile.picture.url, but profile might be missing or picture might not be there. Without checking every step, JavaScript throws an error and your app can crash ❌ It use to happen to me too🥲 I once ran into a bug while building a simple post form where users could optionally add tags through a tags input. Everything was working fine but form submission was slow. Then decided to optimize the image upload flow by compressing images on the front end and uploading them all at once to Cloudinary, which made the form submit faster. While testing, I filled only the required fields and left out the optional tags. That’s when the form crashed. The backend expected a string to split into an array, but since tags was undefined, calling .split(',') threw an error. A simple fix like tags?.split(',') || [] would’ve handled it safely. That’s when optional chaining really made sense to me. ✅ You might be wondering what optional chaining really does to safeguard your code. Let me explain😎 Optional chaining (?.) lets you safely access nested values without having to check each level manually. Instead of writing: if (user && user.profile && user.profile.picture) { // ... } You can simply write: user?.profile?.picture?.url If anything in that chain doesn’t exist (undefined or null), JavaScript just returns undefined instead of crashing 😌 🤔 What’s Really Happening When you use optional chaining (?.), JavaScript checks step by step: 1. Does the part before ?. exist? 2. If yes, it continues 3. If not, it stops and returns undefined It skips the rest of the chain once something is missing. No errors. No drama ✅ 😀 A Simple Example const user = { name: "Ferdinand" }; console.log(user?.profile?.email); // undefined, no error In this case, since profile doesn't exist, JavaScript doesn't even try to check email. It just returns undefined safely. 🔥 When You Should Use It ✅ When working with API data ✅ When reading optional user input ✅ When you’re unsure if certain data exists ✅ When accessing settings or config data It makes your code shorter, cleaner, and safer. ⚠️ But watch out Optional chaining only stops on undefined or null. If a value is false, 0, or an empty string (""), it continues as normal. Also, don’t use it everywhere blindly. It can hide bugs if you're not sure what should or shouldn't be optional 🤨
To view or add a comment, sign in
-
-
🚀 The Hidden Power of Set and Reduce in JavaScript When I first started writing JavaScript, my main goal was just to make things work. But over time, I realized that true skill in programming isn’t about just making it work — it’s about making it faster, cleaner, and smarter. Recently, I discovered a few simple yet game-changing techniques that made my code far more efficient. ⚡ 1️⃣ From Array → Set: A Smarter Way to Handle Lookups In JavaScript, when we use forEach or includes() to check values inside an array, the code scans through each element one by one — which means a time complexity of O(n²) in some cases. Then I learned something powerful — using Set instead of Array can instantly reduce that to O(1) for lookups! const nums = [1, 2, 3, 4, 5, 2, 3]; const numSet = new Set(nums); console.log(numSet.has(3)); // true 👉 The .has() method checks for existence almost instantly because Sets are optimized with hashing under the hood. 🧠 2️⃣ includes() vs has() — Know the Difference Method Used In Complexity Example includes() Array O(n) arr.includes(5) has() Set / Map O(1) mySet.has(5) 💡 Lesson: Choosing the right data structure can drastically improve your code’s performance. 🧮 3️⃣ The Power of reduce(): Beyond Just Summing Values Like most developers, I used to think reduce() was only useful for summing numbers. But the truth is — it’s one of the most versatile and powerful tools in JavaScript. You can use reduce() to group data, count occurrences, find extremes, and even transform complex data — all in a single line. 🌟 Some Powerful reduce() Examples 🔹 Group Products by Category const grouped = products.reduce((acc, item) => { acc[item.category] = acc[item.category] || []; acc[item.category].push(item); return acc; }, {}); 🔹 Find the Highest Priced Product const highest = products.reduce((acc, item) => acc.price > item.price ? acc : item ); 🔹 Calculate Brand-wise Total Sales const brandWise = products.reduce((acc, item) => { acc[item.brand] = (acc[item.brand] || 0) + item.price * item.quantity; return acc; }, {}); 👉 With reduce(), I can now replace multiple loops with a single elegant function. Less code, less complexity, more power. ⚡ 🧩 4️⃣ The Mindset Shift The biggest lesson I’ve learned is this: “Programming isn’t just about making things work — it’s about making them work efficiently.” Now, whenever I write code, I ask myself: ✅ Can I reduce the time complexity? ✅ Am I using the right data structure? ✅ Can this be done in a cleaner, smarter way? That mindset alone changes everything. 🏁 Final Thoughts The Set and Reduce methods might look simple, but when used right, they can drastically improve performance, clarity, and scalability. ✨ Set = Instant lookups ✨ Reduce = Powerful transformations #JavaScript #WebDevelopment #CodingTips #CodeOptimization #ReduceMethod #SetInJavaScript #CleanCode #ProgrammingMindset #SoftwareEngineering #DevelopersJourney
To view or add a comment, sign in
-
#CodingTips #BackendDevelopment #WebDevelopment #Nodejs #Expressjs #SoftwareEngineering #SoftwareDevelopment #Programming The reduce() is one of powerful #JavaScript method and also one of most confusing JavaScript method that even many developers sometimes misunderstand. the JavaScript reduce() method has many functionalities including: - It can be used for grouping objects within an array - It can be used for optimizing performance by replacing filter() method with reduce() in many circumstances - It can be used for summing an array - It can be used for flatten a list of arrays And many more. Of course I am not gonna explain it one by one. But here, I am gonna explain it to you generally, about how does reduce() method work in JavaScript? Now, let's take a look at the code snippet below. At the beginning of iterations, the accumulator (written with the sign {}) starts with the initial empty object. It's just {} (an empty object). While the currentItem is the object with the data inside like: {car_id: 1, etc}. Assume currentItem is: {car_id: 1, etc}, then when below code is executed: if (acc[currentItem.car_id]) Its like the accumulator {} will check if the currentItem.car_id, which is 1 is exist or not?. But because at the beginning is just only {} (an empty object), then it will execute the code below: acc[currentItem.car_id] = [currentItem]; It means it will generate a group of current car_id 1 with its object data, related to car id 1. So, the accumulator becoming like this: { 1: [ // coming from acc[currentItem.car_id {car_id: 1, etc} // coming from currentItem ] } And looping... Still looping until it will check again if acc[currentItem.car_id] (which is car_id is 1 for example) is exist. Because it exist, then acc[currentItem.car_id].push(currentItem); So the result will be like below: { 1: [ {car_id: 1, etc} // coming from currentItem {car_id: 1, etc} // new coming from current item ] } And it always iterate all the data until reach out the end of records. And once it's done, the final result will be like below: { 1: [ {car_id: 1, etc} {car_id: 1, etc} ], 2: [ {...}, {...}, ... ] 3: [ {...}, {...}, ... ] ... } I hope this explanation helps you to understand how JavaScript reduce() method works? Back then, I had a nightmare and difficulties to understand it, but when I know it, I started to realize how powerful it is.
To view or add a comment, sign in
-
-
💡 JavaScript Series | Topic 7 | Part 1 — Memory Management and Garbage Collection in JavaScript 👇 Memory management might not sound glamorous, but it’s one of those fundamental concepts that can make or break your application’s performance. ⚙️ JavaScript hides most of the low-level details — but as your app grows, especially in long-running or real-time systems, understanding how memory is allocated and released becomes critical. 🧠 The Memory Cycle: Allocate → Use → Release Every variable, object, and array in JavaScript follows this 3-step lifecycle 👇 1️⃣ Allocation When you create variables or objects, JavaScript automatically allocates memory for them. You don’t need to explicitly allocate memory (unlike in C/C++). let user = { name: "Rahul" }; // Memory allocated for object let numbers = [1, 2, 3]; // Memory allocated for array 2️⃣ Usage During execution, your code reads and writes from this allocated memory. Accessing object properties or updating values uses this memory space. user.name = "Rahul Jain"; // Updating allocated memory numbers.push(4); // Expands array memory usage 3️⃣ Release Once an object becomes unreachable (i.e., no variables reference it anymore), it becomes eligible for garbage collection. let user = { name: "Rahul" }; user = null; // The object is now unreachable and will be garbage collected ✅ You don’t have to manually free memory — the Garbage Collector (GC) does it for you. ♻️ Understanding Garbage Collection JavaScript primarily uses the Mark-and-Sweep algorithm for garbage collection. Here’s how it works 👇 1️⃣ Roots Identification → GC starts with “roots” like global objects and active function scopes. 2️⃣ Marking → It traverses and marks all objects reachable from these roots. 3️⃣ Sweeping → Unmarked (unreachable) objects are collected and freed from memory. Global Scope ├── user → reachable ✅ └── tempData → no references ❌ (garbage collected) ✅ Reachable = kept in memory ❌ Unreachable = collected and freed ⚠️ Common Causes of Memory Leaks Even with automatic garbage collection, memory leaks can occur if you keep unnecessary references alive: 🔹 Global variables that never get cleared 🔹 Event listeners not removed after use 🔹 Closures that unintentionally hold onto large objects 🔹 Caches that keep growing without pruning Example 👇 let cache = {}; function remember(key, value) { cache[key] = value; // stays in memory forever unless manually deleted } ✅ Solution → Remove references when no longer needed: delete cache[key]; 👉 Follow Rahul R Jain for real-world JavaScript and React interview questions, hands-on coding examples, and performance-driven frontend strategies that help you stand out. #JavaScript #FrontendDevelopment #MemoryManagement #GarbageCollection #PerformanceOptimization #WebDevelopment #ReactJS #NodeJS #NextJS #TypeScript #InterviewPrep #WebPerformance #DeveloperCommunity #RahulRJain #TechLeadership #CareerGrowth
To view or add a comment, sign in
-
💛 #JSMadeEasy with Virashree 🧠 Understanding Scope in JavaScript — The Rulebook for Variables! Ever seen this error? ❌ “x is not defined” That’s when Scope comes into the picture 🌿 Let’s simplify it 👇 ⚙️ What is Scope? - Think of scope as a playground boundary 🎯 - It decides where your variables can be accessed in your code. - If you declare a variable inside a certain boundary (like inside a function), you can’t access it outside — just like you can’t play outside the playground fence! 🏞️ 🌍 1️⃣ Global Scope - Variables declared outside any function or block live in the global world 🌎 - They can be accessed from anywhere in the code. var name = "Virashree"; function greet() { console.log("Hello " + name); } greet(); // ✅ Accessible console.log(name); // ✅ Accessible 💡 Anything defined globally stays accessible everywhere. But be careful — too many globals can cause conflicts in big projects! 🌿 2️⃣ Function Scope - Variables declared inside a function are only accessible inside that function. function greet() { var message = "Hello from inside!"; console.log(message); // ✅ Works } greet(); console.log(message); // ❌ ReferenceError 🎯 JS keeps message private to the function — no one outside can access it! 🌸 3️⃣ Block Scope (ES6 Magic 🌟) - With let and const, JavaScript introduced block-level scope — meaning variables exist only inside { } blocks. { let fruit = "Apple"; const color = "Red"; console.log(fruit, color); // ✅ Works } console.log(fruit); // ❌ ReferenceError 💬 var ignores block scope — but let and const respect it. 🧠 Quick Recap 🧭 Scope Summary: 🌍 Global Scope → Accessible everywhere | var, let, const 🌿 Function Scope → Accessible inside that function only | var, let, const 🌸 Block Scope → Accessible inside { } only | let, const 💛 Takeaway: - Scope controls visibility of variables 🕵️♀️ - Prefer let and const to avoid scope-related bugs - Understanding scope is the foundation for learning Closures (coming next 😉) 💬 Question for you: Which one confused you more when you started — global or block scope? Let’s discuss in the comments 👇 #javascript #frontenddevelopment #reactjs #webdevelopment #learninginpublic #womenintech #JSMadeEasy
To view or add a comment, sign in
-
🚀 Understanding Callbacks, Promises, and Async/Await in JavaScript JavaScript is single-threaded but asynchronous — meaning it can only execute one piece of code at a time, yet still handle tasks like API calls, file reads, or timers without blocking other code. To manage these async operations, JavaScript gives us three main tools: 👉 Callbacks 👉 Promises 👉 Async/Await 🧩 1. Callbacks A callback is a function passed into another function, to be executed later when an operation finishes. function fetchData(callback) { console.log('Fetching data...'); setTimeout(() => { callback('Data received!'); }, 2000); } fetchData((data) => { console.log(data); }); While callbacks work, they can lead to deeply nested and hard-to-read code — aka “callback hell.” getUser(id, (user) => { getPosts(user.id, (posts) => { getComments(posts[0].id, (comments) => { console.log(comments); }); }); }); ⚡ 2. Promises A Promise represents a value that will be available now, later, or never. It has three states: pending, fulfilled, or rejected. function fetchData() { return new Promise((resolve, reject) => { console.log('Fetching data...'); setTimeout(() => { resolve('Data received!'); }, 2000); }); } fetchData() .then((data) => console.log(data)) .catch((error) => console.error(error)); Promises made async code more readable and improved error handling — but there’s an even cleaner way 👇 🧠 3. Async/Await Introduced in ES2017, async and await make asynchronous code look and behave more like synchronous code. function fetchData() { return new Promise((resolve) => { setTimeout(() => { resolve('Data received!'); }, 2000); }); } async function getData() { console.log('Fetching data...'); const data = await fetchData(); console.log(data); } getData(); Error handling is also cleaner with try...catch: async function getData() { try { const data = await fetchData(); console.log(data); } catch (error) { console.error('Error:', error); } }
To view or add a comment, sign in
-
-
Day 19/100 Day 10 of JavaScript Mastering String Methods in JavaScript In JavaScript, strings are sequences of characters used to represent text. But what makes them truly powerful are the built-in string methods that help us manipulate and analyze text efficiently. Let’s explore some of the most useful ones 1. length — Find String Length Returns the number of characters in a string. let name = "JavaScript"; console.log(name.length); // Output: 10 Useful when you need to validate input length, like passwords or usernames 2. toUpperCase() & toLowerCase() — Change Case Converts all characters to upper or lower case. let lang = "javascript"; console.log(lang.toUpperCase()); // JAVASCRIPT console.log(lang.toLowerCase()); // javascript Handy for case-insensitive comparisons. 3. includes() — Check if a Word Exists Checks if a string contains a specific substring. let sentence = "Learning JavaScript is fun!"; console.log(sentence.includes("JavaScript")); // true Perfect for search or filter functions. 4. indexOf() & lastIndexOf() — Find Positions Finds the index of the first or last occurrence of a substring. let text = "Hello JavaScript world!"; console.log(text.indexOf("JavaScript")); // 6 console.log(text.lastIndexOf("o")); // 19 Useful for locating specific patterns in strings. 5. slice() — Extract a Portion Extracts part of a string based on index range. let str = "JavaScript"; console.log(str.slice(0, 4)); // "Java" Often used to trim text or extract keywords. 6. replace() — Replace Text Replaces a substring with another. let msg = "I love JavaScript!"; console.log(msg.replace("JavaScript", "Python")); // "I love Python!" Useful for content formatting or dynamic text updates. 7. trim() — Remove Extra Spaces Removes whitespace from both ends of a string. let input = " Hello World! "; console.log(input.trim()); // "Hello World!" Essential for cleaning user input. 8. split() — Convert String to Array Splits a string into an array based on a delimiter. let fruits = "apple,banana,grape"; console.log(fruits.split(",")); // ["apple", "banana", "grape"] Commonly used when processing CSV data. 9. charAt() — Get Character by Index Returns the character at a specific index. let word = "Hello"; console.log(word.charAt(1)); // "e" 10. concat() — Join Multiple Strings Combines two or more strings. let first = "Hello"; let second = "World"; console.log(first.concat(" ", second)); // "Hello World" Alternative to using + for string concatenation. Quick Tip: All string methods return new strings — they don’t modify the original one since strings in JavaScript are immutable. Final Thought: Mastering string methods helps you handle text data like a pro — from formatting user inputs to processing dynamic content. #10000coders #JavaScript #WebDevelopment #CodingTips #LearnJavaScript #Developers #LinkedInLearning
To view or add a comment, sign in
-
JavaScript’s Tricky Trio: call, apply, and bind — Demystified! If you’ve ever been puzzled by these three, you’re not alone. They all revolve around the mysterious this keyword — which sometimes points to the global object, and sometimes to the object that owns the method. Wouldn’t it be great if we could control what this points to? That’s exactly what these methods let us do 👇 🧠 The Big Three 1️⃣ .call() → Invokes the function immediately and lets you pass arguments one by one. 2️⃣ .apply() → Works like .call(), but accepts arguments as an array. 3️⃣ .bind() → Doesn’t execute right away; instead, it creates a new function with a fixed this and preset parameters. 🧩 Example const person = { firstName: "John", lastName: "Doe", getFullName() { return this.firstName + " " + this.lastName; } }; function greet(lang1, lang2) { console.log(`Hello, I am ${this.getFullName()} and I speak ${lang1}, ${lang2}`); } // call → run immediately greet.call(person, "English", "Spanish"); // apply → same, but arguments in an array greet.apply(person, ["French", "German"]); // bind → create a reusable version const greetPerson = greet.bind(person, "Hindi"); greetPerson("Punjabi"); ✅ Output: Hello, I am John Doe and I speak English, Spanish Hello, I am John Doe and I speak French, German Hello, I am John Doe and I speak Hindi, Punjabi ⚙️ Real-world Uses 🔹 Function Borrowing → Use methods from one object on another. 🔹 Function Currying → Create specialized versions of functions with preset parameters. Example: function multiply(a, b) { return a * b; } const multiplyByTwo = multiply.bind(this, 2); console.log(multiplyByTwo(4)); // 8 const multiplyByThree = multiply.bind(this, 3); console.log(multiplyByThree(4)); // 12 🎯 Key takeaway: 👉 .call() & .apply() → Execute now. 👉 .bind() → Save for later (with context pre-set). Once you understand how they work, they stop being scary — and become some of your most powerful tools for mastering function execution in JavaScript. #JavaScript #WebDevelopment #FrontendDevelopment #JS #CodingTips #TechLearning #WebDevCommunity
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