Javascript For…In syntax issue?

前端 未结 2 1845
被撕碎了的回忆
被撕碎了的回忆 2021-01-28 21:42

The search function in the following code is not working and I believe it has something to do with the For...In loop but I am new to JS and unsure why:

var frien         


        
2条回答
  •  梦谈多话
    2021-01-28 22:19

    The for in loop iterates over keys, not values.

    friend is a string holding the name of each property.
    To get the value, use friends[friend].

提交回复
热议问题