🟨 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗗𝗮𝘆 𝟰𝟲: 𝗔𝘀𝘆𝗻𝗰 & 𝗔𝘄𝗮𝗶𝘁 Some things in JavaScript take time. For example: getting data from a server. JavaScript does not stop everything and wait. That’s why we use async & await. 🔹 𝗔𝘀𝘆𝗻𝗰 async tells JavaScript: “This function may take some time.” 🔹 𝗔𝘄𝗮𝗶𝘁 await means: “Wait here until the result is ready.” 🔹 𝗦𝗶𝗺𝗽𝗹𝗲 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 async function getUser() { const data = await fetch("/user"); console.log(data); } JavaScript waits for the data, then prints it. 🔹 𝗪𝗵𝘆 𝗪𝗲 𝗨𝘀𝗲 𝗜𝘁 • Makes code easy to understand • Runs code in the correct order 🔹 𝗥𝗲𝗮𝗹 𝗟𝗶𝗳𝗲 𝗨𝘀𝗲 Async & await are used when: • Loading data • Submitting forms • Calling APIs 🔹 𝗞𝗲𝘆 𝗣𝗼𝗶𝗻𝘁 Async & await help JavaScript handle slow tasks in a simple way. 💬 GitHub link in the comments #JavaScript #Day46 #100DaysOfCode #Frontend
JavaScript Async Await Simplified
More Relevant Posts
-
🤯 JavaScript Fun Fact That Refuses to Be Fixed Ever checked data types in JavaScript? console.log(typeof null); // object 🤨 console.log(typeof undefined); // undefined Wait… what? You expected null to be null, right? You were right to expect that. 👉 Truth: null is not an object. 👉 Reality: JavaScript says it is. This is an officially acknowledged bug in JavaScript that’s been around for decades 🦕 Why hasn’t it been fixed? Because fixing it would break thousands of websites and popular apps that depend on this wrong behavior. So yes… null means “no value” undefined means “no value” But only one of them lies about who it is 😄 Welcome to JavaScript — where even bugs get legacy support 🐞✨ #JavaScript #WebDevelopment #ProgrammingHumor #DevLife #FunFact #LinkedInTech
To view or add a comment, sign in
-
📌 Understanding the shift() Method in JavaScript The shift() method in JavaScript is used to remove the first element from an array and return that removed element. As a result, the array’s length decreases, and all remaining elements shift one position to the left. 👉 Key Points to Remember: 🔹 It modifies the original array. 🔹 Returns undefined if the array is empty. 🔹 Time complexity is higher compared to pop() because all elements are re-indexed. 🔹 Commonly used in queue-based operations (FIFO – First In, First Out). 🔍 Why it matters: Understanding shift() helps in managing data structures like queues and handling real-time data processing efficiently. #JavaScript #WebDevelopment #FrontendDevelopment #JSArrays #CodingTips #LearnJavaScript
To view or add a comment, sign in
-
-
In JavaScript, types don’t fail loudly — they fail silently. Knowing the data type of a variable is a small habit that prevents big production issues, especially at system boundaries like APIs and user input. https://lnkd.in/ec-_rDWp #JavaScript #SoftwareEngineering #CleanCode #Reliability #CTOInsights #IceBearSoft
To view or add a comment, sign in
-
-
So, JavaScript is all about functions and objects. It's like the foundation of the whole language. You gotta understand how they work. A function is basically a block of code that does something - and you can use it over and over. Simple. But here's the thing: there are a few ways to create functions in JavaScript. You've got your function declaration, function expression, and arrow function - each with its own twist. For example, you can do something like console.log(greet("Ajmal")) - and that's a function in action. Or, you can create a function like const add = function (a, b) { return a + b; } - and that's another way to do it. And then there's the arrow function, like const multiply = (a, b) => a * b - which is pretty cool. Now, objects are a different story. They're like containers that store data in key-value pairs - which is really useful for managing state and behavior. You can think of an object like a person - it's got characteristics (like name, age, etc.) and actions (like walking, talking, etc.). So, objects are all about combining state and behavior in a neat little package. And that's why you can use them to store and manage data in a really efficient way. Check out this article for more info: https://lnkd.in/gTMkkSGP #JavaScript #Functions #Objects
To view or add a comment, sign in
-
🔹 Day 2/30 – JavaScript Data Types JavaScript is a dynamically typed language, which means variables can change their type at runtime. This flexibility is powerful, but it can also cause bugs if we don’t understand data types properly. Data types decide what kind of value a variable holds — text, number, true/false, or nothing at all. Even simple applications rely heavily on correct data handling. Understanding data types is extremely important when dealing with: User input API responses Conditions and calculations This topic helped me understand why JavaScript sometimes behaves in unexpected ways. ❓ Which JavaScript data type confused you the most when you started? #JavaScript #ProgrammingBasics #LearningJourney
To view or add a comment, sign in
-
-
The `this` keyword in JavaScript has confused developers for years. Arrow functions were supposed to simplify things, but they actually introduce a completely different behaviour that catches many off guard. Here's what I wish someone had told me earlier: **Regular functions are dynamic.** The value of `this` depends entirely on how you call them. Call `person.greet()` and `this` is the person object. Assign that same method to a variable and call it? Now `this` is undefined (or the global object). **Arrow functions are lexical.** They don't have their own `this` at all. They inherit it from wherever they were defined. This makes them perfect for callbacks and event handlers where you want to preserve context, but terrible for object methods. The classic gotcha: ```javaScript const person = { name: "Alice", greet: () => { console.log(`Hello, ${this.name}!`); } }; person.greet(); // "Hello, undefined!" ``` That arrow function doesn't see the person object as `this`. It sees whatever `this` was in the surrounding scope when it was created. But in a class with callbacks? Arrow functions shine: ```javaScript class Button { handleClick = () => { console.log(this.label); // 'this' always works } } ``` **My rule of thumb:** Use arrow functions for callbacks, event handlers, and anywhere you need to preserve the outer context. Use regular functions for object methods and constructors where you want dynamic binding. Understanding this distinction has saved me countless debugging hours. What about you? Have you been bitten by unexpected `this` behaviour? Full breakdown with examples: https://lnkd.in/gdcyTibZ
To view or add a comment, sign in
-
✅ Understanding undefined vs null Clearly This morning’s code was: let x; console.log(x); console.log(typeof x); x = null; console.log(x); console.log(typeof x); 💡 Correct Output undefined undefined null object Yes , the last line surprises many 😄 Let’s understand why. 🧠 Simple Explanation : 🔹 Line 1: console.log(x); let x; x is declared But no value is assigned So JavaScript automatically gives it: undefined ✔ Output: undefined 🔹 Line 2: console.log(typeof x); The type of undefined is: "undefined" ✔ Output: undefined 🔹 Line 3: x = null; Here, we explicitly assign null. Important rule 👇 👉 null means intentional absence of value So: console.log(x); ✔ Output: null 🔹 Line 4: console.log(typeof x); This is the classic JavaScript quirk 👀 Even though x is null: typeof null returns: "object" ✔ Output: object 📌 This is a known bug in JavaScript kept for backward compatibility. 🎯 Key Takeaways : undefined → variable declared, value not assigned null → value explicitly set to “nothing” typeof undefined → "undefined" typeof null → "object" ❌ (historical JS bug) 📌 That’s why many developers check null like this: x === null 💬 Your Turn Did you already know typeof null is "object"? 😄 Comment “Knew it 👍” or “Learned today 😮” #JavaScript #LearnJS #FrontendDevelopment #CodingInterview #Basics #TechWithVeera #WebDevelopment
To view or add a comment, sign in
-
-
JavaScript Basics I Learned Today – Variables & Data Types 🚀 Today I learned some important fundamentals of JavaScript variables: 🔹 Variables in JavaScript Variables are like containers that store data in memory. 🔹 Data Types stored in variables A variable can store: String Number Array And other data types 🔹 JavaScript is a dynamically typed language This means: The type of a variable is decided at runtime You can change the value and type of a variable while the program is running Example: var a = 67; console.log(a); // 67 a = "Harry"; console.log(a); // Harry 🔹 Statically typed languages In languages like C, you must declare the type first (int, float, char) and cannot change it later. 🔹 Literal & Identifier let a = 7; a → identifier 7 → literal 🔹 Rules for naming variables ✔ Allowed: letters, digits, _, $ ❌ Cannot start with a number ❌ Reserved words cannot be used Examples: let harry8 = 7; // valid let 8harry = 7; // ❌ not allowed let var = 7; // ❌ reserved keyword 🔹 JavaScript is case-sensitive let Harry; let haRRY; // Both are different variables 📌 Key takeaway: JavaScript variables are flexible, memory containers, and their values can change during program execution. Learning step by step and staying consistent 💪 #JavaScript #WebDevelopment #LearningJourney #FrontendDevelopment #CodingBasics
To view or add a comment, sign in
-
Day 61 – JavaScript Variables (var, let & const) Today I focused on understanding JavaScript variables and how different keywords affect scope, reusability, and reassignment while storing and managing data in programs. Topics covered: JavaScript Variables Variables as containers used to store data/values Understanding keywords as reserved words with special meaning Displaying output using document.writeln() var Globally scoped and accessible anywhere Allows re-declaration and re-assignment Last assigned value is retained during execution let Block-level scoped Does not allow re-declaration within the same scope Allows re-assignment Helps avoid unexpected behavior in larger programs const Block-level scoped Does not allow re-declaration or re-assignment Used for values that should remain constant throughout execution Understanding these differences is essential for writing clean, predictable, and error-free JavaScript code, especially when working on real-world applications. Continuing the learning journey with consistency and focus. #JavaScript #Variables #WebDevelopment #FrontendDevelopment
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
https://github.com/nishchaya2k