我正在尝试修复代码,但我停在了两行非常奇怪的代码,我无法理解它们。所有行:
//Extraction of urls
let f = !this.last_product_url
for(const productLink of productLinks) {
const url = await productLink.getAttribute('href')
if(!f) {
f = url === this.last_product_url
f && productUrls.push(url)
}
else {
productUrls.push(url)
}
}
这两行是做什么的:
f = url === this.last_product_url
f && productUrls.push(url)
最佳答案
f = url === this.last_product_url
会将 url === this.last_product_url
的结果赋值给 f。
f && productUrls.push(url) 同下:
if(f) productUrls.push(url)
关于javascript - Node js。 s1 = s2 === s3 和 s1 && s2 怎么理解?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62676779/