typescript array of property of object code example
Example 1: array objects to array of one property
let result = objArray.map(a => a.foo);
Example 2: typescript array of objects
interface Product {
name: string;
price: number;
description: string;
}
let pen: Product = {
name: "Pen",
price: 1.43,
description: "Userful for writing"
}
let products: Product[] = [];
products.push(pen);
console.log(products);
Example 3: map a property from array of objects javascript
var result = objArray.map(function(a) {return a.foo;});
Example 4: typescript array of objects
interface User {
[index: number]: {
firstname: string;
lastname: string;
age: number;
}
}