title: JavaScript move an item of an array to the front
body: <p>I want to check if an array contains <code>"role"</code>.  If it does, I want to move the <code>"role"</code> to the front of the array.</p>
  
  <pre><code>var data= ["email","role","type","name"];
  if ("role" in data) data.remove(data.indexOf("role")); data.unshift("role")
  data;
  </code></pre>
  
  <p>Here, I got the result:</p>
  
  <p><code>["role", "email", "role", "type", "name"]</code></p>
  
  <p>How can I fix this?</p>