<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>map的用法</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> </style> <script> let arr = [ {title:'aaaaa', read:100, hot:true}, {title:'bbbb', read:100, hot:true}, {title:'cccc', read:100, hot:true}, {title:'dddd', read:100, hot:true} ]; let newArr = arr.map((item, index, arr)=>{ let json={} json.t = `^_^${item.title}-----`; json.r = item.read+200; json.hot = item.hot == true && '真棒!!!'; return json; }); console.log(newArr); </script> </head> <body> </body> </html>
ES6中关于map的用法。
最新推荐文章于 2025-06-05 13:56:58 发布