add(server.tests.test2): 添加实验2的内容,将pdf里面标重要的进行提取出来
This commit is contained in:
25
Server/tests/test2/important/find.js
Normal file
25
Server/tests/test2/important/find.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// find(callbackFn)
|
||||
|
||||
const stus = [
|
||||
{ name: '张三', score: 59 },
|
||||
{ name: '老钟', score: 95 },
|
||||
{ name: 'SB', score: 80 }
|
||||
];
|
||||
|
||||
// 筛选第一个 score >= 60 的信息
|
||||
const rst = stus.find(item => { return item.score >= 60 })
|
||||
console.log(rst)
|
||||
|
||||
// 浅表拷贝,rst的修改,会导致stus中对应数据的修改
|
||||
rst.score = 100
|
||||
console.log(stus)
|
||||
|
||||
/*
|
||||
# node find.js
|
||||
{ name: '老钟', score: 95 }
|
||||
[
|
||||
{ name: '张三', score: 59 },
|
||||
{ name: '老钟', score: 100 },
|
||||
{ name: 'SB', score: 80 }
|
||||
]
|
||||
*/
|
||||
Reference in New Issue
Block a user