let user: { id: number, name: string }[] = [
{ "id": 0, "name": "ABC" },
{ "id": 1, "name": "XYZ" }
];
let dataList: { id: number, name: string, address: string , pin: string, comment: string}[] = [];
If I want to move the user data array to dataList array how can I do that?
If I use map function then do I need to initialize empty data for other fields for dataList?
2
Answers
Yes, I need to initialize empty data.
Here is a simple example.
map return an array, so you simply
In "strict mode", if you don’t want add all the properties with a default value you should use some like
See the implicit convert "as". Generally you use an interface
Yes, a "map" if "somelike"