我[2016,2017,2018,2019]删除范围
的阵列我有一个范围fromValue 2017 toValue 2017
因此所得阵列应采用[2017]由于我需要删除fromValue和toValue之间的任何范围。
我已经写了下面的代码这是只有消除2016和2018,但不是2019年
哪些错误我在做什么,有没有什么办法尤为明显要做到这一点?
gNodeIDs.forEach(function (item) {
alert("Before if" + item);
if (item >= fromValue) {
if (item <= toValue) {
}
else
{
alert("removing" + item);
var index = test.indexOf(item);
if (index >= 0) {
test.splice(index, 1);
}
}
}
else {
alert("removing" + item);
var index = test.indexOf(item);
if (index >= 0) {
test.splice(index, 1);
}
}
});
怎么样?使用过滤器? – SmartestVEGA