Get an error when I call object's properties in Array

前端 未结 4 1503
悲&欢浪女
悲&欢浪女 2021-01-28 15:10

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

4条回答
  •  鱼传尺愫
    2021-01-28 15:23

    it should be less than length not less than equal to

    for (var i = 0; i < users.length; i++) {
       console.log(users[i].firstName + " is " + users[i].age + " years old!");
    }
    

提交回复
热议问题