错误:
<--- Last few GCs --->
[873:0x1020aa000] 47109 ms: Scavenge 2107.9 (2131.9) -> 2092.1 (2131.9) MB, 0.3 / 0.0 ms (average mu = 0.995, current mu = 0.999) allocation failure
[873:0x1020aa000] 47231 ms: Scavenge 2107.9 (2131.9) -> 2092.1 (2131.9) MB, 0.2 / 0.0 ms (average mu = 0.995, current mu = 0.999) allocation failure
[873:0x1020aa000] 47353 ms: Scavenge 2107.9 (2131.9) -> 2092.1 (2131.9) MB, 0.2 / 0.0 ms (average mu = 0.995, current mu = 0.999) allocation failure
<--- JS …
Run Code Online (Sandbox Code Playgroud) 假设我有一个对象数组:
let arr = [
{
name: 'Jack',
id: 1
},
{
name: 'Gabriel',
id: 2
},
{
name: 'John',
id: 3
}
]
Run Code Online (Sandbox Code Playgroud)
我需要检查该数组是否包含名称“Jack”,例如使用:
if (arr.includes('Jack')) {
// don't add name to arr
} else {
// push name into the arr
}
Run Code Online (Sandbox Code Playgroud)
但是 arr.includes('Jack') 返回 false,如何检查对象数组是否包含名称?