ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
接json数组, foreach读取指定元素: 简单一些的json数组: ``` var jsonArr = [65, 44, 12, 4]; jsonArr.forEach(jsonArrItem) function jsonArrItem(item, index, arr){ alert(item); } ``` 复杂一些的json数组: ``` var jsonArr = [{ "firstName": "Bill", "lastName": "Gates" }, { "firstName": "George", "lastName": "Bush" }, { "firstName": "Thomas", "lastName": "Carter" } ]; jsonArr.forEach(jsonArrItem) ; function jsonArrItem(item, index, arr){ alert(item.firstName); } ```