• @[email protected]
    link
    fedilink
    31 day ago

    What’s awful about this example? The only thing I do is access an object member. Does your code not do that??

    • @BrianTheeBiscuiteer
      link
      0
      edit-2
      1 day ago

      What’s the purpose of foo? Why an ambiguous single character variable? What if the property was there but the value was null? Why not use (assuming JS) optional chaining?

      I’d approach it more like this:

      function getWhatevrProp(userData) (
        const default = { whatevr: "n/a" };
      
        return { ...default, ...userData }.whatevr;
      }
      

      Sorry, read too fast the first time. It’s more likely Python. I also don’t know Python well enough to give recommendations on that.

      • @calcopiritus
        link
        316 hours ago

        Lmao, and they say dynamic typing is supposed to speed up the developer.

      • @[email protected]
        link
        fedilink
        31 day ago

        It’s an example to demonstrate that linters cannot reliably detect variable name typos - you need static types. None of the stuff you mentioned is relevant.

        The typo in your example is also undetectable by linters. I think you’re missing the point.