Javascript Scopes in 30 seconds. Many bugs in JavaScript come from misunderstanding scope. Scope decides where variables live and who can access them. var → function scoped let / const → block scoped #JavaScript #CodingJourney
Understanding JavaScript Scopes in 30 Seconds
More Relevant Posts
-
Got a minute for some JavaScript? 🍵 What does this code output? Answers 🔍 >>> - ReferenceError: message is not defined Why? Because let lives only inside the block where it’s created. In this code, message is created inside the *if {}* and *else {}* blocks. When JavaScript reaches *console.log(message)*, it is already outside those blocks, so the variable no longer exists. #javascript #webdevelopment
To view or add a comment, sign in
-
-
🚀 JavaScript Fundamentals Series — Part 7 Most developers use arrays every day… But many don't fully understand array methods. This guide explains the most important ones: • map() • filter() • reduce() These methods help you write cleaner and more functional JavaScript. Once you master them, your code becomes much more expressive. Full guide 👇 https://lnkd.in/dZTRRCUx #javascript #webdevelopment #functionalprogramming
To view or add a comment, sign in
-
Got a minute for some JavaScript? ⌨️ What does this code output? Answer 🔍 >>> 105 When using *call*, all arguments after the first one are passed to the function parameters. Unlike *apply*, you don’t need to pass them as an array. Here, a single array [5] is passed, so a becomes [5]. When adding a number and an array in JavaScript, the array is converted to a string, and concatenation occurs. #javascript #webdevelopment
To view or add a comment, sign in
-
-
JAVASCRIPT NOTES — PART 3 (Async JavaScript) Synchronous code is easy to follow. Asynchronous code is where real confusion begins. This post covers: • Callbacks and why they became messy • Promises and their states • async / await for cleaner flow • Error handling with try–catch • The Event Loop and execution order • Microtasks vs callback queue Understanding async JavaScript isn’t about memorizing syntax — it’s about knowing when and why code executes. If the event loop ever felt confusing, this one is for revision. #JavaScript #WebDevelopment #FrontendDeveloper #LearningInPublic #InterviewPrep #AsyncJavaScript #Consistency
To view or add a comment, sign in
-
Got a minute for some JavaScript? 🍒 What does this code output? Answers 🔍 >>> - "Tom says meow" - TypeError: c.createKitten is not a function - "Kitty says meow" Why the TypeError? *createKitten* is a static method - it lives on the *Cat* constructor, not on instances. *c* is an instance, so it cannot access static methods. Only *Cat.createKitten()* works. #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
-
-
Type Coersion in JavaScript. 1. "2" + "2", JavaScript thinks these are two strings that's why result will be 22. Here + is considered as concatenation operator. 2. So now 22 - "2" = 20, When we use -,/,÷ in between two variables JavaScript consider both variables as number that's why result of 22-"2"=20 #javascript #webdevelopment
To view or add a comment, sign in
-
-
Tip Calculator The game is simple to fetch the data from the HTML, make calculations and then update it via Javascript. The question is how, let's see more in the video. #learninginpublic #JavaScript #Codinglife #learningvideoediting
To view or add a comment, sign in
-
JavaScript Tip 💡: Convert a String to an Array using Spread Syntax! Did you know? Converting a string to an array in JavaScript can be as easy as spreading it! The spread syntax (...) breaks down each character in the string into individual elements, making it perfect for quick string-to-array transformations. Watch the short video for an example! Hope this helps ✅ Do Like 👍 & Repost 🔄 #html #css #javascript #react #nextjs
To view or add a comment, sign in
-
Part 2 of using reduce() method in JavaScript. Let’s talk about getting the product of numbers in JavaScript Arrays. #JavaScript #WebDevelopment #CodingTips #LearnToCode #softwaredeveloper
To view or add a comment, sign in
More from this author
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