title: JavaScript - String Comparision fails even though both are same
body: <p>The following code is failing when I call it with <code>isValid("()")</code>. When I debugged it, I see that the comparision fails at <code>parantheses[parantheses.length - 1] === p</code> even though both the values are same. Can anyone tell why this is failing ?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var isValid = function(s) {
    const openParantheses = new Set("(", "{", "[");
    const closedParantheses = new Set(")", "}", "]");
    const parantheses = [];
  
    for (let p of s) {
      if (openParantheses.has(p)) {
        parantheses.push(p);
      } else if (closedParantheses.has(p)) {
        if (parantheses[parantheses.length - 1] === p) {
          parantheses.pop();
        } else {
          return false;
        }
      }
    }
  
    if (parantheses.length &gt; 0) {
      return false;
    }
  
    return true;
  };
  
  console.log(isValid("()"))</code></pre>
  </div>
  </div>
  </p>
  
  <p>Also when I do console.log(<code>Inside If - ${parantheses}</code>) This isnt printing the parantheses array as an array but just giving out values without array notation. Is this something expected ?
  Thanks.</p>