For in

    0

    18

    Jose Romero

    TypeScript recipes

    The code is iterating through the myobject object, looking for a key called key. If it finds the key, it checks to see if it exists on Object.hasOwnProperty. If it does, it then retrieves the object at that key from myobject, and assigns it to element.

    Shortcut: for.in

    for (const key in myobject) {
      if (Object.hasOwnProperty.call(myobject, key)) {
        const element = myobject[key];
      }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.