企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
接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); } ```