我将使用JS中的过滤器过滤对象列表
dataid
我的elm.identifiant == this.dataService.getcurrentId()
为空,而true
在给定时刻为option[selected]
答案 0 :(得分:2)
与functional-programming
无关。尝试下面的代码
let f = a => { a == 1 };
f(1); // undefined
let g = a => a == 1;
g(1); // true
let h => a => { return a == 1; };
h(1); // true
最好不要使用内联函数来调试高阶函数。
答案 1 :(得分:1)
对于unsigned char
中的多行代码,您需要明确提及Array.filter()
。对于return
这样的单行,我们不指定infosStructured.filter((elm) => elm)
关键字。
return
如果您不需要在过滤器中使用let dataid = infosStructured.filter(elm => {
console.log(elm.identifiant);
console.log("matching value", elm.identifiant == this.dataService.getcurrentId()); // I get a true value
elm.identifiant == this.dataService.getcurrentId();
return elm;
});
console.log(dataid);
,则可以在不使用console.log()
关键字的情况下将其更改为:
return