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
JavaScript Filter Functionality with parseInt and Boolean
More Relevant Posts
-
📊 Yesterday poll answer and explanation - Day 5 console.log(0 && "Hello"); console.log("Hello" && 0) Rule of && in JavaScript (Important ⭐) 👉 It evaluates left to right 👉 It returns the first falsy value, 👉 If no falsy value is found, it returns the last truthy value These are falsy values in JavaScript false, 0, "", null, undefined, NaN 🎯 Final output 0, 0 Hope this explanation is helpful😊 #JavaScript #FrontendDeveloper #WebDevelopment #LearningJavaScript #InterviewPrep
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
-
-
📊 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
-
Javascript challenge! let a = 10; let b = 20; [a, b] = [b, a]; console.log(a, b); Drop your answer in the comments #JavaScript #CodingChallenge #WebDevelopment #FrontendDeveloper #LearnToCode
To view or add a comment, sign in
-
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
-
-
Advanced Tip: Use 'Function Nodes' in n8n to write custom JavaScript and extend your power. 💻⚖️ When pre-built nodes aren't enough, code your way to victory. Get the JS snippets for n8n at smartflowslab.com. #n8nTutorial #JavaScript #AdvancedNoCode #AutomationStrategy
To view or add a comment, sign in
-
-
Advanced Tip: Use 'Function Nodes' in n8n to write custom JavaScript and extend your power. 💻⚖️ When pre-built nodes aren't enough, code your way to victory. Get the JS snippets for n8n at smartflowslab.com. #n8nTutorial #JavaScript #AdvancedNoCode #AutomationStrategy
To view or add a comment, sign in
-
-
But 𝚏𝚘𝚛𝙴𝚊𝚌𝚑 doesn’t handle 𝗽𝗿𝗼𝗺𝗶𝘀𝗲𝘀. The loop won’t wait. If you need 𝘀𝗲𝗾𝘂𝗲𝗻𝘁𝗶𝗮𝗹 𝗲𝘅𝗲𝗰𝘂𝘁𝗶𝗼𝗻, use: 𝚏𝚘𝚛 (𝚌𝚘𝚗𝚜𝚝 𝚒𝚝𝚎𝚖 𝚘𝚏 𝚒𝚝𝚎𝚖𝚜) { 𝚊𝚠𝚊𝚒𝚝 𝚜𝚊𝚟𝚎(𝚒𝚝𝚎𝚖); } If you need 𝗽𝗮𝗿𝗮𝗹𝗹𝗲𝗹 𝗲𝘅𝗲𝗰𝘂𝘁𝗶𝗼𝗻, use: 𝚊𝚠𝚊𝚒𝚝 𝙿𝚛𝚘𝚖𝚒𝚜𝚎.𝚊𝚕𝚕(𝚒𝚝𝚎𝚖𝚜.𝚖𝚊𝚙(𝚜𝚊𝚟𝚎)); Small detail. Big difference in real applications. #JavaScript #WebDevelopment #Async #LearningInPublic
To view or add a comment, sign in
-
-
I learned about default parameters in JavaScript. When we assign a value using = in a function parameter, that value works as a default. If no argument is passed, instead of getting undefined, the default value is used. This works in regular functions and arrow functions, and it makes the code safer and cleaner. Small concept, but very useful in real projects. #JavaScript #ES6 #Functions #LearningJourney #WebDevelopment
To view or add a comment, sign in
-
🔥 JavaScript Concept: Hoisting — Code Moves Before Execution Hoisting is JavaScript’s behavior of moving declarations to the top of their scope before execution. 🔹 Key Points ✔ "var" is hoisted and initialized as "undefined" ✔ "let" & "const" are hoisted but NOT initialized (Temporal Dead Zone) ✔ Function declarations are fully hoisted 🔹 Example console.log(a); // undefined var a = 10; console.log(b); // Error let b = 20; 💡 Understanding hoisting helps prevent unexpected bugs. Write predictable code → Prefer "let" and "const" ✔ #JavaScript #Hoisting #CleanCode #Developers
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