In typescript code I have an array with objects in it. When I call \"getUsers(users)\" function, it returns the result as I need, but in console I get this error \"Uncaught Type
You can use for-of loop
let users = [
{
firstName: "John",
lastName: "Doe",
age: 34
},
{
firstName: "Jack",
lastName: "Jackson",
age: 23
},
{
firstName: "Ann",
lastName: "Watson",
age: 24
}
];
function getUsers(users) {
for (var user of users) {
console.log(user.firstName + " is " + user.age + " years old!");
}
}
getUsers(users);