I want to check if an array contains \"role\". If it does, I want to move the \"role\" to the front of the array.
\"role\"
var data= [\"ema
You could take the delta of the check with the wanted value at top.
var data = ["email", "role", "type", "name"]; data.sort((a, b) => (b === 'role') - (a === 'role')); console.log(data);