console.log("1") Promise.resolve(console.log("3")) setTimeout(()=> console.log("4")) console.log("2") Usually answer would be 1 2 3 4 right but no It will be 1 3 2 4 At first glance it looks like create a resolved promise that logs 3. But the important detail is what happens first: JavaScript evaluates arguments to a function call before calling the function. 3 printed synchronously, immediately. #javascript #reactjs #microtask #macrotask #eventloop #developer #web #development
Why JavaScript prints 1 3 2 4 instead of 1 2 3 4
More Relevant Posts
-
📅 Day 29 – Web Development Journey with Rohit Negi Today I dived into JavaScript Events and Event Handlers — one of the most exciting parts of frontend development 🖱️💻 Here’s what I learned: ✅ Common event types: click, mouseover, keydown, submit ✅ Attaching handlers: Inline onclick vs addEventListener() ✅ Making pages interactive: updating content, styles, or behavior dynamically based on user actions 💭 Key takeaway: Events are the bridge between users and web applications. Understanding them is the first step to building truly dynamic, responsive websites. ⚡ #JavaScript #WebDevelopment #FrontendDeveloper #LearningInPublic #100DaysOfCode #DOM #Events
To view or add a comment, sign in
-
-
⚙️ The Hidden Story Behind JavaScript Polyfills Back in the early 2010s, the web was evolving fast — HTML5, ES5, and modern APIs were everywhere. But one thing wasn’t keeping up: old browsers (yes, Internet Explorer). Developers needed a way to use new features like "map" or "Promise" without breaking compatibility. So they started writing small scripts that filled the gaps — mimicking modern APIs in older browsers. In 2010, web developer Remy Sharp gave these scripts a name: “Polyfills” — inspired by Polyfilla, the paste used to fill cracks in walls before painting. 🎨 Just like Polyfilla smooths out walls, polyfills smooth out differences between browsers. Even today, every time you use a polyfill or Babel, you’re quietly patching the web — one feature at a time. ⚡ #JavaScript #Frontend #HistoryOfTech #Polyfill
To view or add a comment, sign in
-
⚡ JavaScript Performance Tips That Matter 🔥 Debouncing - Limit function calls 🔥 Memoization - Cache expensive calculations 🔥 Code splitting - Load what you need 🔥 Web Workers - Heavy tasks off main thread Optimize for user experience, not just code elegance. #JavaScript #Performance #WebOptimization #UserExperience
To view or add a comment, sign in
-
Excited to share my latest project: a secure and customizable Password Generator built with React! 🔐 This application helps you create strong, random passwords to enhance your online security. It's designed with a modern UI and a focus on user experience. Key Features: - **Customizable Length**: Generate passwords from 8 to 128 characters. - **Character Types**: Include or exclude uppercase, lowercase, numbers, and symbols. - **Copy to Clipboard**: Easily copy your new password with a single click. - **Responsive Design**: Works seamlessly on all screen sizes. Technologies Used: - React 19 - Vite - Tailwind CSS - Font Awesome I had a great time building this project and would love for you to check it out! You can find the project on my GitHub: GitHub repo Link: https://lnkd.in/gPrgzZkb Live Website: https://lnkd.in/gwCaQU_y #React #Vite #TailwindCSS #JavaScript #WebDevelopment #PasswordGenerator #Security #OpenSource
To view or add a comment, sign in
-
Today, I focused on understanding the DOM (Document Object Model) one of the most important concepts in web development. The DOM allows JavaScript to interact with HTML and make a webpage dynamic and interactive. In simple words I learned how JavaScript can select, change, and update elements on the page in real-time. Some key things I practiced today: Selecting elements using getElementById and querySelector Changing text and styles with JavaScript Handling button click events Updating the UI based on user actions Learning the DOM felt like unlocking a new superpower in web development! 💡⚡ Small steps every day are shaping my skills more clearly. #WebDevelopment #JavaScript #DOM #FrontendDevelopment #LearningInPublic #CodingJourney #FullStackDeveloper #TechCommunity
To view or add a comment, sign in
-
🧠 Day 49 | Web Development Challenge Today’s lecture: The Event Loop in JavaScript 🔄 Finally understood how JavaScript manages asynchronous tasks through the Call Stack, Web APIs, and Callback Queue. It’s fascinating how a single-threaded language can handle multiple operations seamlessly! ✨ Key Insight: > The Event Loop is what keeps JavaScript non-blocking — letting your code run smoothly without freezing the UI. #JavaScript #EventLoop #AsyncJS #WebDevelopment #Frontend #LearningJourney #CodeNewbie
To view or add a comment, sign in
-
💻 Prerequisites for Web Development Before diving into coding, set up your workspace! Use VS Code as your code editor, install the Live Server extension for instant preview, and understand basic file formats — .html, .css, .js — the building blocks of the web. #WebDevelopment #CodingBasics #HTML #CSS #JavaScript #VSCode #LearnToCode #FrontendDevelopment #TechSkills
To view or add a comment, sign in
-
✨Built a Simple Skill Manager Web Application (HTML | CSS | JavaScript) Today I created a lightweight and interactive Skill Manager tool using core frontend technologies. This app allows users to add skills dynamically and displays them instantly with a clean and minimal UI. Features:- Add skills in real-time Instant DOM updates without reloading Clean, responsive UI Simple and beginner-friendly JavaScript logic Focus on event handling and DOM manipulation 🛠️ Tech Stack HTML5 for structure CSS3 for styling and layout JavaScript (Vanilla JS) for dynamic functionality
To view or add a comment, sign in
-
⚡ Events in JavaScript Events in JavaScript are actions or occurrences that happen in the browser — like a user clicking a button, pressing a key, or submitting a form. 🔹 Events respond to user actions such as clicks, mouse moves, key presses, or page loads. 🔹 Event listeners (addEventListener) let you handle these actions efficiently. 🔹 There are various types — Mouse Events, Keyboard Events, Form Events, and Clipboard Events. 🔹 You can even create custom events for advanced user interactions. Events are what bring life to web pages — turning static content into an interactive experience. #JavaScript #WebDevelopment #Frontend #WebDesign
To view or add a comment, sign in
-
🧱 Day 8 – The DOM (Document Object Model) Today, I explored how JavaScript interacts with the DOM — the core of web interactivity! Learned how to access elements using getElementById, querySelector, and how to change content dynamically. Also tried creating and deleting elements using createElement() and appendChild(). 💡 It’s amazing how manipulating the DOM can completely change a webpage’s behavior! 💬 What’s your favorite DOM method to use? #JavaScript #DOM #FrontendDevelopment #WebDevelopment #CodingJourney #React #Angular #Vue #GeeksforGeeks
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