Loop add new record to array in typescript [closed]

If you want to add each item in options to opt, then:

let opt = [];

let options = [
    { name: "option1", value: 1 },
    { name: "option2", value: 2 }
]

options.forEach(x => opt.push(x));

Leave a Comment