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

    Continue Reading

    6 Best Free and Open Source C# Object-Relational Mapping Software

    Development

    How AI-powered Zoom Docs can improve your meeting workflow

    Development

    Octo: An Open-Sourced Large Transformer-based Generalist Robot Policy Trained on 800k Trajectories from the Open X-Embodiment Dataset

    Development

    Windows 7 would boot much slower if you used specific wallpapers — A veteran Microsoft engineer links the bug to a “simple programming error”

    News & Updates

    Highlights

    Development

    World CyberCon META Wraps Up, Highlighting Dubai’s Expanding Cybersecurity Prowess

    May 27, 2024

    Dubai, UAE – May 24, 2024 – The Cyber Express proudly announces the successful conclusion…

    Useful Tips for Customizing IBM Sterling Store Engagement

    August 21, 2024

    Fediverso: Un Moderno Ritorno al Passato!

    February 24, 2025

    CVE-2025-4191 – PHPGurukul Employee Record Management System SQL Injection

    May 2, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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