标签:lis pre 返回 var sid list body console html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
var nubList = [
{
expressId: "00001", //快递单号ID
expressNum: "数据1"
},
{
expressId: "00002", //快递单号ID
expressNum: "数据2"
},
{
expressId: "00003", //快递单号ID
expressNum: "数据3"
},
{
expressId: "00004", //快递单号ID
expressNum: "数据4"
}
];
var nub = nubList.find(nub => nub.expressId == "00002");
console.log(nub.expressId);
var nub1 = nubList.filter(nub => nub.expressId == "00002");
console.log(nub1[0].expressId);
</script>
</body>
</html>
复制代码
数据来自网上。
find和filter这两个的区别是:
find返回的是一条数据;
filter返回的是一个数组;
标签:lis pre 返回 var sid list body console html
原文地址:https://www.cnblogs.com/mmit/p/14116605.html