title: Setting boolean flags in JS / jQuery
body: <p>I'm going nowhere with apparently a simple task of trying to set a boolean flag in Js / JQuery. I'm expecting that after btn1 click the flags should change (globally). But I likely misunderstand some inner works of JS and after clicking btn2 the status of flags stays exactly as initially declared - how can I go about this?</p>
  
  <p>JS:</p>
  
  <pre><code>$(document).ready(function(){
    var $btn1 = $("#btn1");
    var $btn2 = $("#btn2");
    var active1 = true;
    var active2 = false;
  
    $btn1.click(function(){
      $active1 = false;
      $active2 = true;
      alert("after btn1 click: --&gt; " + " active1: " + active1 + ", active2: " + active2);
    });
  
    $btn2.click(function(){
     // If clicked first on btn1 I'm expecting active1=false; active2=true; ??
          alert("after btn2 click: " + " active1: " + active1 + ", active2: " + active2);
    });
  });
  </code></pre>
  
  <hr>
  
  <pre><code>   &lt;button id="btn1"&gt;Button1&lt;/button&gt;
     &lt;button id="btn2"&gt;Button2&lt;/button&gt;
  </code></pre>
  
  <p><a href="https://jsfiddle.net/Turo/wtksmam0/" rel="nofollow">JsFiddle Here</a></p>