當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
JS数组遍历-forEach()、map()方法
生活随笔
收集整理的這篇文章主要介紹了
JS数组遍历-forEach()、map()方法
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
[{a:'1',b:'11'},{a:'2',b:'21'},{a:'3',b:'31'}].forEach((item, index, array) => {let c = '';let d = '21';c = d == item.b ? item : '';console.log(c)
})
?
// 列表頁展示searchRulesByPage(pageModel: PageModel, searchObj: MchtRuleSearchObj) {const _searchObj = ObjectUtils.removeEmptyAttr(searchObj);return this.networkService.post({urlStr: '/mchrules/list', body: {...pageModel, ..._searchObj}}).map(res => {// 格式化數(shù)據(jù) 1=> true 0 =》falseif (res.code === '200') {res.data.list.map((val, index, array) => {val.status = val.status === '1' ? true : false;return val;});}console.dir(res);return res;});} // 批量修改商戶規(guī)則batchEditMchRules(dialogObj, mchs: any[]) {// 批量修改mchs.forEach((value, index, array) => {for (const prop in dialogObj) {if (dialogObj.hasOwnProperty(prop) === true) {value[prop] = dialogObj[prop];}}});// 格式化狀態(tài)字段mchs.forEach((value, index, array) => {value.status = value.status ? '1' : '0';});return this.networkService.post({urlStr: '/mchrules/update', body: mchs}).map(res => {return res;});}?
MAINDATASERVICE.get_dossBasicData().then(res => {this.options = res['leadsFeedbackReasons'].map((val, index, arr) => {return val = Object.assign({},val,{isActive: false});});console.log('this.options',this.options)})?
總結
以上是生活随笔為你收集整理的JS数组遍历-forEach()、map()方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 云记APP如何导入ward文档
- 下一篇: gradle idea java ssm