title: How to simply detect browser type with JQuery or JavaScript?
body: <p>I am using JavaScripts <code>lastIndexOf()</code> which doesnt work in IE so I must write an alternative code.</p>
  
  <p>I simply want an if statement to do something like:</p>
  
  <pre><code>if(IE = true){
    //run alternative to lastIndexOf()
  }
  </code></pre>
  
  <p>But I am really struggling with finding a way to achieve this.</p>
  
  <p>So far I have tried the following:</p>
  
  <p>JQuery's <code>.browser</code> is deprecated.</p>
  
  <p><code>.support</code> seems to only detect certain facets or features of a
     browser.</p>
  
  <p>Modifying <code>.support</code> with JavaScript, as <a href="https://stackoverflow.com/questions/8890460/how-to-detect-ie7-and-ie8-using-jquery-support">here</a>, wont work and
     throws errors.</p>
  
  <p>The <code>hasClass()</code> method no longer works:</p>
  
  <pre><code>&lt;!--[if lt IE 7]&gt;      &lt;html class="ie6"&gt; &lt;![endif]--&gt;
  &lt;!--[if IE 7]&gt;         &lt;html class="ie7"&gt; &lt;![endif]--&gt;
  &lt;!--[if IE 8]&gt;         &lt;html class="ie8"&gt; &lt;![endif]--&gt;
  &lt;!--[if gt IE 8]&gt;&lt;!--&gt; &lt;html&gt;         &lt;!--&lt;![endif]--&gt;
  if ($('html').hasClass('ie7');
  </code></pre>
  
  <p>Would anyone know a simple way to just detect the browser type?</p>