三味线
三味线
Published on 2020-03-27 / 144 Visits
0
0

js forEach中的continue,break

#js

Lodash 中的 forEach 函数

var array = ["a", "b", "c", "d"];
_.forEach(array, function (item) {
    if (item == "a") {
        return true; // continue 
    } else if (item == "d") {
        return false; // break 
    }
    print(item);
});

输出:

b
c


Comment