add key pair to each object in array



    majid ghasemi

    The code creates a new DataList that contains a map() function call to v => ({...v, key:}) . The map() function takes in a JavaScript object and returns a new DataList with the same items, but with the key property set to the object's id value.

    Library: react

    const newArr1 = => ({...v, key:}))
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.