𝗘𝘃𝗲𝗿 𝘀𝗲𝗲𝗻 𝘁𝗵𝗶𝘀 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁? 𝚌𝚘𝚗𝚜𝚘𝚕𝚎.𝚕𝚘𝚐([𝟷,𝟸,𝟹]+[𝟺,𝟻,𝟼]) The output is: "𝟭,𝟮,𝟯𝟰,𝟱,𝟲" Why? Because the + operator triggers type 𝙘𝙤𝙚𝙧𝙘𝙞𝙤𝙣. Both arrays are converted to strings ("1,2,3" and "4,5,6") before concatenation. This is a great reminder that: JavaScript is flexible, but that flexibility can be surprising Understanding coercion rules helps prevent subtle bugs Clear intent matters use methods like concat() or the spread operator for arrays Small details like this separate writing code that works from writing code that’s reliable. #JavaScript #WebDevelopment #SoftwareEngineering #ProgrammingTips #CleanCode
Aparna Shaju’s Post
More Relevant Posts
-
In JavaScript, even a small detail like a leading zero in a number can change the output. let a = 0676; console.log(a); This logs 446 instead of 676 because numbers starting with 0 are interpreted as octal (base-8) values. JavaScript automatically converts them before execution. Why this matters: JavaScript supports multiple number systems Implicit conversions can affect logic and calculations Writing explicit, predictable code avoids hidden bugs Understanding how the language interprets data at a fundamental level is essential for writing reliable and maintainable code. #JavaScript #ProgrammingFundamentals #WebDevelopment #SoftwareEngineering #CleanCode #CoreConcepts
To view or add a comment, sign in
-
🧠 JavaScript Hoisting Confusion That Breaks Logic Look at this code: console.log(sum(2, 3)); var sum = function (a, b) { return a + b; }; Most expect it to print 5. Instead, it throws an error. Only declarations are hoisted, not function expressions. Use function declarations when order matters. #JavaScript #Hoisting #JSConcepts #FrontendDevelopment #WebDevelopment #CleanCode #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 1/30 — JavaScript Fundamentals Refresh ⚙️ Revisited closures and higher-order functions through a deceptively simple problem. A small reminder that in production code, clarity between return and side-effects like console.log matters more than it looks. Sharpening fundamentals to eliminate blind spots that scale into bugs. #JavaScript #EngineeringCraft #FullStackDeveloper #LeetCode #Consistency
To view or add a comment, sign in
-
-
🚀 #Day 14/100 – 📌JavaScript Logic & Control Flow Today, I focused on understanding how JavaScript makes decisions and handles logic. Topics covered today: ✅Linking JavaScript files and using console.log() ✅Template literals for cleaner output ✅Comparison and logical operators ✅Conditional statements: if, else if, else ✅Nested conditions and truthy vs falsy values ✅switch statements ✅Alerts and prompts for basic user interaction Practicing these concepts helped me understand how real programs control flow and respond to different conditions. Step by step, moving from syntax to thinking in code. Day 14 complete ✅ 👍🏻 #Day14 #JavaScript #ControlFlow #FrontendDevelopment #100DaysOfCode
To view or add a comment, sign in
-
-
Day 42/100 – An Important JavaScript Concept Many People Ignore Not all performance issues come from bad code. Sometimes they come from too many function calls. 📌 Topic: Debouncing vs Throttling Both are used to control how often a function executes. ✅ Debouncing Runs the function only after a certain time has passed since the last event. Example use cases: • Search input • Form validation 👉 Executes when user stops typing. ✅ Throttling Runs the function at a fixed interval, no matter how many times the event occurs. Example use cases: • Scroll events • Window resize 👉 Executes every X milliseconds. Understanding these concepts helps build faster and smoother applications. Small improvements. Big impact. On to Day 43 🚀 #100DaysOfCode #JavaScript #WebDevelopment #LearningInPublic #Consistency #FrontendDevelopment
To view or add a comment, sign in
-
-
#CVEAISlop PeteReport Version 0.5 allows an authenticated admin user to inject persistent JavaScript code inside the markdown descriptions while creating a product, report or finding. https://lnkd.in/ewCDxyVq
To view or add a comment, sign in
-
-
A nice feature of closures in JS/TS is that they allow encapsulation for plain objects (classes can achieve this too, by prefixing private fields with '#'). A closure is “the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment).” (MDN docs) In the simple example below, the factory function createObject returns an object whose methods close over the privateValue parameter, so they can keep accessing it even though it isn’t stored on the object itself. 👨💻 #typescript #javascript #closures
To view or add a comment, sign in
-
-
Day 2/30 — JavaScript Fundamentals Refresh ⚙️ Went deeper into execution flow and edge cases that silently break logic. Reinforced how defaults, falsy values, and function returns can mislead even clean-looking code. Small fundamentals, when ignored, compound into production-level bugs. Precision is the real performance win. #JavaScript #EngineeringCraft #FullStackDeveloper #Consistency
To view or add a comment, sign in
-
-
Hoisting confusion cost me 2 hours debugging last week. The fix wasn’t changing code. It was understanding what JavaScript actually does. Hoisting doesn’t mean JavaScript “moves code up”. What really happens: • JS allocates memory before execution • var is initialized as undefined • let and const are hoisted but blocked (Temporal Dead Zone) • Function declarations are stored fully in memory That’s why: – var gives undefined – let / const throw ReferenceError – Function declarations work before definition Example 👇 console.log(a); // undefined console.log(b); // ReferenceError console.log(sum(2,3)); // 5 var a = 10; let b = 20; function sum(x, y) { return x + y; } Understanding execution > memorizing rules. #JavaScript #FrontendDevelopment #LearningInPublic #SDE
To view or add a comment, sign in
-
I was debugging a feature that kept producing wrong results, even though the logic looked correct. No errors. No crashes. Everything *seemed* fine. I kept changing the implementation, but nothing improved. The real issue wasn’t the code. It was an assumption I never questioned. I assumed my string was being modified in place. But in JavaScript, strings are immutable. So every change required creating a new copy. One missed reassignment was breaking the logic. Once that assumption was fixed, the solution was obvious. Bugs are symptoms, not the root cause 💡 #SoftwareEngineering #JavaScript #Debugging #WebDevelopment #DeveloperLife #LearningInPublic
To view or add a comment, sign in
-
Explore related topics
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
I remember this thing from the previous weeks. This made me go through a quick comparison between dynamically typed and statically typed languages. I am currently focused on C#, and we don't have this type of coercion because it is strongly typed. That's helpful anyways ..Good job 👍