Stop using delete to remove Array elements! 🛑 If you think the answer to the code below is 3, you're falling for a classic JavaScript trap. let numArr = [1, 2, 3, 4]; delete numArr[2]; Console.log(numArr.length) #JavaScript #WebDevelopment #CodingTips #SoftwareEngineering #FrontendDev #CleanCode
More Relevant Posts
-
𝗟𝗼𝗼𝗽𝗶𝗻𝗴 𝗦𝘁𝗮𝘁𝗲𝗺𝗲𝗻𝘁𝘀 𝗜𝗻 𝗝𝗦 Looping statements in JavaScript repeat a block of code until a condition becomes false. You use loops to make your code shorter and easier to manage. JavaScript provides the following loops: - for Loop: used when you know how many times the loop should run - while Loop: runs as long as the given condition is true You can use loops to print numbers, find multiples, or count divisors. For example, you can print numbers from 1 to 5 using a for loop: for (let i = 1; i <= 5; i++) { console.log(i); } This prints: 1 2
To view or add a comment, sign in
-
#motimeline v2.13.1 — category filter bug fix and new version online After filtering, badges were stacking on top of each other on the spine. The column algorithm was reading stale positions from hidden items. Fix: visible items get a clean left/right recalculation after every filter change. Hidden items are fully excluded from position and badge-offset calculations. npm install motimeline@latest #javascript #webdev #opensource #bugfix #pixelquadrat
To view or add a comment, sign in
-
-
Responsive two-column timeline layout library — plain JavaScript, zero dependencies, MIT licensed. new version 2.13.1 reachable here https://lnkd.in/eV65B7Rs want to see in action? https://www.mattopen.com/ #javascript #webdev #opensource #bugfix #pixelquadrat #mattopen
#motimeline v2.13.1 — category filter bug fix and new version online After filtering, badges were stacking on top of each other on the spine. The column algorithm was reading stale positions from hidden items. Fix: visible items get a clean left/right recalculation after every filter change. Hidden items are fully excluded from position and badge-offset calculations. npm install motimeline@latest #javascript #webdev #opensource #bugfix #pixelquadrat
To view or add a comment, sign in
-
-
🚀 JavaScript Challenge #1 What will be the output? console.log(1 + "2" + 3); Think before you answer 👇 Most people get this wrong. 👉 JS converts numbers to strings when needed: 1 + "2" → "12" "12" + 3 → "123" ✅ Output: "123" 💡 Lesson: Type coercion can silently change your logic. Did you get it right? 😄 Follow for more daily Challenges
To view or add a comment, sign in
-
Day 5/100 of JavaScript Today’s Topic: Closures in JavaScript A closure is created when a function remembers variables from its outer scope even after that outer function has finished execution Example: function outer() { let count = 0; return function inner() { count++; return count; }; } const counter = outer(); counter(); // 1 counter(); // 2 Here, the "inner" function forms a closure over the "count" variable. Even though "outer()" has finished execution, "count" is preserved. Key understanding: Closures help in maintaining state and also enable data privacy by restricting direct access to variables #Day5 #JavaScript #100DaysOfCode
To view or add a comment, sign in
-
#javascript #javascriptTips Converting input type number by using parseInt or Number() function or using a plus operator for instance const num = +value. We can instead use the valueAsNumber property which gives the value as number type simple 🪄 Picture Credit: Steve Sewell 🙌
To view or add a comment, sign in
-
-
Day 1 — Reverse a String (JavaScript) Problem Write a function that reverses a given string. Example Input: "hello" Output: "olleh" Approach Start from the last character of the string and iterate backwards. Keep adding each character to a new string until the loop finishes. Code function reverseString(str){ let reversed = "" for(let i = str.length - 1; i >= 0; i--){ reversed += str[i] } return reversed } console.log(reverseString("hello")) What I Learned Basic string traversal and how iteration works from the end of a string. #javascript #frontenddeveloper #codingpractice #dsa
To view or add a comment, sign in
-
-
setTimeout does nothing inside the JavaScript engine. It's a label. A facade. When you call it, JS hands the work off to a browser feature - the actual timer lives outside JavaScript entirely. The browser runs it independently while JS continues on to the next line. All the features we think of as "JavaScript" - timers, network requests, DOM interactions - are actually browser APIs. JS just has labels that trigger them. This is how JS avoids blocking. It doesn't wait. It delegates. The result comes back later, through a controlled channel called the callback queue. Next: the event loop - the single mechanism that controls when deferred code is allowed back into JavaScript. #JavaScript #WebDevelopment #Programming #SoftwareEngineering
To view or add a comment, sign in
-
𝗦𝗮𝗺𝗽𝗹𝗲 𝗼𝗳 𝗙𝘂𝗻𝗰𝗍𝗶𝗼𝗻 You write a function once, you use it many times. In JavaScript, a function is a block of code that performs a specific task. You have several types of functions, including: - Function Declaration - Function Expression - Arrow Function - Anonymous Function - Named Function - Callback Function - IIFE - Recursive Function - Higher-Order Function - Constructor Function - Generator Function - Async Function - Method Source: https://lnkd.in/gRkjbBt8
To view or add a comment, sign in
-
𝗧𝗲𝗺𝗽𝗹𝗮𝗧𝗲 𝗟𝗶𝗧𝗲𝗿𝗮𝗹𝘀 𝗜𝗻 𝗝𝗮𝗙𝗮𝘀𝗰𝗿𝗶𝗽𝘁 When you start building strings in JavaScript, you often use the + operator. This works, but it gets messy and hard to read as your code grows. You have variables like name and age. You want to build a message with these variables. The old way is to use the + operator: let name = "Alice" let age =
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