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 can sort the array and specify that the value "role" comes before all other values, and that all other values are equal:
"role"
var first = "role"; data.sort(function(x,y){ return x == first ? -1 : y == first ? 1 : 0; });
Demo: http://jsfiddle.net/Guffa/7ST24/