(wx.getStorageSync('logs') || []).map

1. 微信小程序里面获取存储 wx.getStorageSync('logs') || []

const logs = wx.getStorageSync('logs') || []

 

2. map 是什么意思? map():通过指定函数处理数组中的每一个元素,并返回一个处理后的新数组。

语法是   array.map(function(currentValue,index,arr),thisValue)

 

举例:

返回原数组中每一个元素的2倍值

var arrays = [1,3,5,7,9];

arrays.map(x => x*2);

返回: [2, 6, 10, 14, 18]

 

3. x => x*2 是箭头函数,也是匿名函数

posted @ 2025-11-20 09:10  429512065  阅读(6)  评论(0)    收藏  举报