easyclick 判断数组是否不为空

/**
 * @author Mr_老冷 QQ1920712147
 * @description 判断数组是否不为空
 * @param arr {Array}  数组
 * @return {boolean}
 */
function isNotEmptyArray(arr) {
    if (!arr) return false
    return arr.length !== 0;
}
let res = getLastNotification("com.x", 100)
if (isNotEmptyArray(res)) {
    for (let i = 0; i < res.length; i++) {
        logd(res[i]);
    }
}

猜你喜欢

转载自blog.csdn.net/mr_oldcold/article/details/116097133