querySelector vs querySelectorAll – I learned this the hard way 🤦🏻 Just wasted 2 hours because my code only worked on the first button. All the others? Dead. Turns out querySelector() literally does what it says—it queries for ONE selector. I needed querySelectorAll() to grab all the buttons, then loop through them. Sometimes the answer is right there in the name and you still miss it 🤦🏻 #JavaScript #WebDevelopment #100DaysOfCode #LearningInPublic
querySelector vs querySelectorAll: A Common JavaScript Mistake
More Relevant Posts
-
Got a minute for some JavaScript? ⚠️ What does this code output? Answer 🔍 >>> Internal error: error1 The inner *try* block throws an error, which is caught by the inner *catch* block. It prints the error message, and the execution continues after the inner *try/catch* block, so the outer catch block is not triggered. In short: the first *catch* is triggered, the second one is not. #javascript #webdevelopment
To view or add a comment, sign in
-
-
Got a minute for some JavaScript? 😚 What does this code output? Answer 🔍 >>> undefined I don’t really like questions where you just have to be attentive, but I think this is something worth paying attention to. To get the number of entries in a *Map*, you use the *.size* property, not *.length* like in arrays. In short: .length --> Arrays, Strings, function parameters .size --> Map, Set #javascript #webdevelopment
To view or add a comment, sign in
-
-
I learned about truthy and falsy values in JavaScript. Non-zero numbers, non-empty strings, arrays, and objects return truthy values. On the other hand, 0, empty strings (""), null, and undefined are falsy. Understanding truthy and falsy behavior helps a lot when working with conditions and logical statements. Strengthening my JavaScript fundamentals step by step. #JavaScript #ProgrammingBasics #WebDevelopment #LearningJourney
To view or add a comment, sign in
-
⭐ JavaScript String Methods – Uppercase, Lowercase & Length .. ⭐ ▪️ toUpperCase()—Converts a string to all capital letters. ▪️ toLowerCase()—Converts a string to all small letters. ▪️ Length—Returns the total number of characters in a string (including spaces). Understanding these basic string methods is a strong step toward mastering JavaScript fundamentals. ▪️ #StringMethodinJavascript #HTML #CSS #JAVASCRIPT #WebDevelopment #Coding #Frontend. 💻
To view or add a comment, sign in
-
💻 JavaScript Beginner Level Practice – Reverse String Today I practiced a simple JavaScript program to reverse a string. function reverseString(str){ return str.split("").reverse().join(""); } console.log(reverseString("hello")); 📌 Output: olleh 💡 Explanation: This program reverses a string using "split()", "reverse()", and "join()" methods. Input: hello Output: olleh #JavaScript #CodingPractice #WebDevelopment #LearningToCode
To view or add a comment, sign in
-
-
🚀 30 Days of JavaScript Tricky Questions – Day 2 🧠 Topic: Closures in JavaScript function outer() { let outerVar = "I am from outer function!"; function inner() { let innerVar = "I am from inner function!"; console.log(outerVar); console.log(innerVar); } return inner; } const myClosure = outer(); myClosure(); Can you guess what should be logs in the console🤔 💬 Drop your answer in the comments #JavaScript #JSClosures #FrontendDeveloper #WebDevelopment #100DaysOfCode #LearningJavaScript #InterviewPrep
To view or add a comment, sign in
-
🚀 30 Days of JavaScript Tricky Questions – Day 1 Let’s start with async / await + event loop 🧠 async function foo() { console.log('A'); setTimeout(() => console.log('B'), 0); await Promise.resolve(); console.log('C'); } foo(); console.log('D'); ❓ What will be the output and why? 💬 Drop your answer in the comments #JavaScript #JSInterview #AsyncJavaScript #FrontendDeveloper #WebDevelopment #30DaysOfJavaScript
To view or add a comment, sign in
-
📊 Day 6 - poll answer and explanation console.log(0 || "Hello"); console.log("Hello" || 0); Rule of || in JavaScript (Important ⭐) 👉 It evaluates left to right 👉 It returns the first truthy value 👉 If all values are falsy, it returns the last value These are falsy values in JavaScript false, 0, "", null, undefined, NaN 🎯 Final output "Hello" "Hello" Hope this explanation is helpful😊 #JavaScript #JavaScriptTricks #LogicalOperators #JavaScriptInterview #FrontendDevelopment #WebDevelopment #CodingConcepts #LearnJavaScript #DeveloperCommunity #30DaysOfJavaScript #100DaysOfCode #TechCommunity #DailyLearning
To view or add a comment, sign in
-
A classic JavaScript trap 🧠 What will this log? const values = [ 1, 1, true, false, 0, '', {}, [] ]; console.log( values.filter( parseInt ) ); console.log( values.filter( Boolean ) ); For the first log, is it [1, 1]? Or something else? What about the second one? Think first. Then run it. The result is not what most people expect 😄 #JavaScript #CodingChallenge #WebDevelopment
To view or add a comment, sign in
-
-
What is Zone.js, the security camera analogy, 3-step how it works, setTimeout & HTTP real examples... #Angular #ZoneJS #TypeScript #Frontend #WebDevelopment #ChangeDetection #AngularPerformance #JavaScript #FrontendDeveloper #SoftwareEngineering #100DaysOfCode #WebDev
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