gpt4 book ai didi

javascript - 干燥 JavaScript 片段

转载 作者:行者123 更新时间:2023-11-28 16:06:08 26 4
gpt4 key购买 nike

下面的内容可以干一点吗?

if(totals[label]) {
totals[label] += increment;
} else {
totals[label] = increment;
}

基本上,当 totals[label] === undefined 时,我有一个特殊情况,因为每当 typeofincrement == 时,undefined +increment === NaN =“数字”

最佳答案

totals[label] = (totals[label] || 0) + increment;

关于javascript - 干燥 JavaScript 片段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14864876/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com