Be aware that checking permissions in Javascript isn't safe. I don't know if that is what you are doing but just a heads up
Dec 11, 2021
4
Level 4
Can include() be used the other way around?
Hi all,
I have 4 roles in my app, during loops I would like to check my data like this: //if role includes admin or super-admin or manager if(item.role.includes(['admin', 'super-admin', 'manager'])){ //do this }
//If role includes user if(item.role.includes(['user'])){ //do that }
Would this be the correct way to check if one of the given role exists in a loop?
Thank you.
Level 102
I think I understand what you are after. You can invert the if statement with a !
if(! item.role.includes(['admin', 'super-admin', 'manager'])){
1 like
Please or to participate in this conversation.