jQuery cookie sets boolean value as string
<p>I'm working with a cookie, setting other code varibles using the value of the cookie.</p>

<p>I have defined data about the default state of the cookie as so:</p>

<pre><code>const Cookie = {
  config: {
    name: 'Test_Cookie',
    expire: 1,
    value: true,
  },
...
}
</code></pre>

<p>When criteria are met, the cookie gets set for the first time, using <code>this.config.value</code> to set the value of the cookie to <code>true</code>:</p>

<pre><code>  setCookie: function () {
    if (!this.isCookieSet()) {
      $.cookie(this.config.name, this.config.value, this.config.expire);
    }
  },
</code></pre>

<p>However, I am finding when I return the cookie value in the code I get <code>"true"</code> back as a string rather than just <code>true</code>. For example (name changed in above example for simplicity):</p>

<p><a href="https://i.stack.imgur.com/FY1OX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FY1OX.png" alt="enter image description here"></a></p>

<p>If I try to do a comparison on the <code>value</code> of the cookie, and use <code>=== true</code> I get a false result. If I do <code>=== "true"</code> then I get a true result:</p>

<pre><code>showStuff = $.cookie('Test_Cookie') === "true"; // showStuff = true;
</code></pre>

<p>OR</p>

<pre><code>showStuff = $.cookie('Test_Cookie') === true; // showStuff = false;
</code></pre>

<p><strong>Why does the variable type of the cookie value change when set?</strong></p>