Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 17, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 17, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 17, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 17, 2025

      Microsoft’s allegiance isn’t to OpenAI’s pricey models — Satya Nadella’s focus is selling any AI customers want for maximum profits

      May 17, 2025

      If you think you can do better than Xbox or PlayStation in the Console Wars, you may just want to try out this card game

      May 17, 2025

      Surviving a 10 year stint in dev hell, this retro-styled hack n’ slash has finally arrived on Xbox

      May 17, 2025

      Save $400 on the best Samsung TVs, laptops, tablets, and more when you sign up for Verizon 5G Home or Home Internet

      May 17, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      NodeSource N|Solid Runtime Release – May 2025: Performance, Stability & the Final Update for v18

      May 17, 2025
      Recent

      NodeSource N|Solid Runtime Release – May 2025: Performance, Stability & the Final Update for v18

      May 17, 2025

      Big Changes at Meteor Software: Our Next Chapter

      May 17, 2025

      Apps in Generative AI – Transforming the Digital Experience

      May 17, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft’s allegiance isn’t to OpenAI’s pricey models — Satya Nadella’s focus is selling any AI customers want for maximum profits

      May 17, 2025
      Recent

      Microsoft’s allegiance isn’t to OpenAI’s pricey models — Satya Nadella’s focus is selling any AI customers want for maximum profits

      May 17, 2025

      If you think you can do better than Xbox or PlayStation in the Console Wars, you may just want to try out this card game

      May 17, 2025

      Surviving a 10 year stint in dev hell, this retro-styled hack n’ slash has finally arrived on Xbox

      May 17, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»CodeSOD: While This Works

    CodeSOD: While This Works

    December 30, 2024

    Rob‘s co-worker needed to write a loop that iterated across every element in an array. This very common problem, and you’d imagine that a developer would use one of the many common solutions to this problem. The language, in this case, is JavaScript, which has many possible options for iterating across an array.

    Perhaps that buffet of possible options was too daunting. Perhaps the developer thought to themselves, “a for each loop is easy mode, I’m a 10x programmer, and I want a 10x solution!” Or perhaps they just didn’t know what the hell they were doing.

    Regardless of why, this is the result:

    try {
      var index = 0;
      while (true) {
        var nextItem = someArray[index];
        doSomethingWithItem(nextItem);
        index++;
      }
    } catch (e) { }
    

    This code iterates across the array in an infinite while loop, passing each item to doSomethingWithItem. Eventually, they hit the end of the array, and someArray[index] starts returning undefined. Somewhere, deep in doSomethingWithItem, that causes an exception to be thrown.

    That is how we break out of the loop- eventually something chokes on an undefined value, which lets us know there’s nothing left in the array.

    Which puts us in an interesting position- if anyone decided to add better error handling to doSomethingWithItem, the entire application could break, and it wouldn’t be obvious why. This is a peak example of “every change breaks somebody’s workflow”, but specifically because that workflow is stupid.

    [Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.

    Source: Read More 

    news
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleTackling cloud native turbulence with platform engineering
    Next Article Ghostty Is a Fast, Feature-Rich, Cross-Platform Terminal

    Related Posts

    Development

    February 2025 Baseline monthly digest

    May 17, 2025
    Development

    Learn A1 Level Spanish

    May 17, 2025
    Leave A Reply Cancel Reply

    Hostinger

    Continue Reading

    AI agents are transforming the software development life cycle

    Development

    A spring iPhone launch? Apple might shake up its iPhone release schedule – here’s why

    News & Updates

    I’ve tested hundreds of laptops. The Asus Zenbook S 16 has one of the most unique designs I’ve seen

    Development

    Kraken vs Certik: A Dispute Over a $3 Million Zero-Day and Bug Bounty Ethics

    Development

    Highlights

    Development

    Enhancing Laravel Authorization with Backed Enums

    March 17, 2025

    Enhance your Laravel application’s security model with backed enum support for permissions. This feature provides…

    Una serie di patch per il kernel Linux farà ordine (una volta per tutte) sulle mitigazioni ai bug delle CPU

    January 24, 2025

    DOOM: The Dark Ages is available now for Premium Edition owners

    May 15, 2025

    6 ways continuous learning can advance your career

    January 12, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.