javascript中常用方法

1. .some()方法

let rolesm = ['admin'];
let roles = ['admin','developer'];
// let res = roles.some(role => rolesm.includes(role));

function isper(username){
    if(username == 'admin'){
        return true;
    }
}

let res = roles.some(isper);

if(res){
    console.log(res)
    console.log("success")
}else{
    console.log("err")
}


//输出结果
true
success

~~~