🚀 JavaScript Trick You Should Know! What do you think the result will be? 👇 "5" + 2 // ? "5" - 2 // ? ✅ "5" + 2 → "52" ✅ "5" - 2 → 3 Why? Because (+) combines strings, while (-) forces JavaScript to convert "5" into a number. A small example — but it shows how type coercion can completely change your output. ⚡ #JavaScript #FrontendDevelopment #CodingTips
JavaScript Trick: String vs Number Operations
More Relevant Posts
-
Think you can start a new line after `return`? Cute. JavaScript's "helpful" semicolon insertion will stab you in the back. `return\n{ user: 'Gabo' }` becomes `return;`. Your function now silently returns `undefined`. The object vanishes. Is this a clever rule for cleaner code, or a silent logic-killer that semicolons exist to prevent? #GaboTips #JavaScript
To view or add a comment, sign in
-
"this" in JavaScript isn’t what you think it is. It doesn’t mean “this function”, it means “the object that called the function.” That’s why "this" changes depending on how the function is called. Arrow functions don’t have their own this. They inherit it from their parent scope, perfect for callbacks, but confusing inside classes and objects. That’s why in React or classes you often see .bind(this) in event handlers because without it, "this" gets lost when the function runs. So next time "this" is undefined, remember, It’s not you. It’s JavaScript being… JavaScript. #this #javascript
To view or add a comment, sign in
-
🚀 Dynamic DOM Manipulation with JavaScript 💻 Just explored how to create an unordered list dynamically using JavaScript DOM methods like createElement(), appendChild(), and textContent. No hardcoding — everything gets generated through JS! 🔥 This small step helped me understand how JavaScript interacts with the DOM and how elements can be created, modified, and added dynamically. 🌿 💡 Tech used: HTML, JavaScript (DOM) 📁 Output: “fruit 1 to fruit 5” list generated automatically 🍎 #JavaScript #FrontendDevelopment #WebDevelopment #LearningJourney #DOM #CodingPractice #DeveloperInProgress #WomenInTech #HTML #JSBeginners #CodeNewbie
To view or add a comment, sign in
-
-
𝐈 𝐛𝐞𝐭 𝐲𝐨𝐮 𝐝𝐢𝐝𝐧’𝐭 𝐤𝐧𝐨𝐰 𝐭𝐡𝐢𝐬… . . . There’s a 30-𝐲𝐞𝐚𝐫-𝐨𝐥𝐝 𝐛𝐮𝐠 in JavaScript — and it’ll never be fixed. 𝐭𝐲𝐩𝐞𝐨𝐟 𝐧𝐮𝐥𝐥 === "𝐨𝐛𝐣𝐞𝐜𝐭"; // 𝐭𝐫𝐮𝐞 🤯 This is not a quirk — it’s a mistake. When JS was created in 1995, 𝐧𝐮𝐥𝐥 was stored as all 0’s in memory. Objects also used 0 as a type tag. So JS confused them. Now fixing it would break the web. 💀 #JavaScript #ProgrammingHistory #WebDev #JavaScript #WebDevelopment #ProgrammingHistory
To view or add a comment, sign in
-
Lately, I’ve been revisiting some core JavaScript concepts, and today I stumbled upon something I hadn’t really paid attention to before — Symbols. They’re not something you see in everyday code, but I found them really interesting. A Symbol is a unique and immutable value that can be used as a key in objects. What I like about Symbols is that each one is completely unique, even if it has the same description: Symbol("id") === Symbol("id"); // false They can be super useful when you need unique property keys in an object — especially to avoid accidental overwriting. Even if I might not use them often, I enjoy discovering these little parts of JavaScript that make the language more powerful than it first seems. #JavaScript #WebDevelopment #LearningEveryDay
To view or add a comment, sign in
-
-
Hot take: 3+ nested callbacks = you're doing it wrong 🔥 Just published: "Understanding Asynchronous JavaScript: From Callbacks to Cleaner Code" Includes the workflow diagram everyone's been asking for 👇 https://lnkd.in/gcfBqVR7 #JavaScript #WebDev #DevTips
To view or add a comment, sign in
-
🧠Did you know ? Even an empty JavaScript file isn't actually empty. When JS runs, the engine automatically creates: 1) Global Execution Context 2) Global Object (window) 3) this -> points to window in browsers ( In Browsers this === window ) Before a single line of your code executes, memory is allocated and the first execution context is already sitting in the call stack. That is the hidden setup behind every JavaScript program. #Javascript #Webdevelopment #Frontend
To view or add a comment, sign in
-
-
🤔 What's the difference between 𝗺𝗮𝗽()and 𝗳𝗹𝗮𝘁𝗠𝗮𝗽() in #JavaScript? #map() transforms each element in an array and returns a new array with the same length. #flatMap() does the same but flattens nested arrays by one level, perfect for unwrapping results without extra .flat() calls! This makes your code shorter and more efficient for handling nested data. Which do you prefer using in your projects, and why? Share your thoughts! #CleanCodeSolutions #JavaScript #WebDevelopment #Fullstack
To view or add a comment, sign in
-
-
The JavaScript filter() method is a powerful way to create a new array containing only the elements that meet a certain condition. It goes through each item in the array and returns the ones that pass the test you provide. For example, to get all even numbers from an array: javascript const numbers = [1, 2, 3, 4, 5]; const evens = numbers.filter(num => num % 2 === 0); console.log(evens); // Output: [2, 4] Use filter() whenever you need to sift through data and extract only what’s relevant, making your code more declarative and concise! #JavaScript #WebDevelopment #CodingTips #ArrayMethods
To view or add a comment, sign in
-
Today is Day 10, and I explored some of the most important function-related concepts in JavaScript: ✅ Pure Functions ✅ First-Class & Higher-Order Functions ✅ map(), filter(), and reduce() ✅ Argument Object & Rest Parameter ✅ Variable Scope (Global, Local, Block) ✅ Scope & Scope Chain ✅ Recursion & Closures #Day10 #JavaScript #FrontendDevelopment #100DaysOfCode #LearningInPublic
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