title: Why equal number comparison is returning false?
body: <p>I have an application in NodeJs with Express, where I get two values:</p>
  <p>One is an <code>INTEGER</code> type from Google BigQuery.
  The other is an <code>int autoincrement length 11</code> id from MySql via Sequelize.</p>
  <p>They are equal values, but when I compare the two I got false:</p>
  <pre><code>laboratorios.some(laboratorio =&gt; {
      console.log(venda.fornecedor, typeof venda.fornecedor)
      console.log(laboratorio.laboratorio_id, typeof laboratorio.laboratorio_id)
      console.log(laboratorio.labotatorio_id == venda.fornecedor)
      if (laboratorio.labotatorio_id == venda.fornecedor){
          lab = laboratorio.lab_razao_social
          return true;
      }
      return false;
  });
  </code></pre>
  <p>Returns on console:</p>
  <pre><code>2128 number
  2128 number
  false
  </code></pre>
  <p>As you can see, they are both &quot;number&quot; of value 2128, I compare them with <code>==</code>, and still get false. I tried comparing them with <code>===</code> just in case, but also returned false.</p>
  <p>Here is how I retrieve the bigquery value:</p>
  <pre><code>let query = `SELECT itens.laboratorio_id AS fornecedor,
              ...
              from produtos,
              UNNEST(itens) AS itens
              WHERE ...`;
  const options = {
      query: query + ` GROUP BY itens.laboratorio_id;`,
      params: params
  };
  var [vendas] = await bigqueryClient.query(options).catch(err =&gt; {
      ...
  });
  </code></pre>
  <p>Here is how I retrieve the Sequelize value:</p>
  <pre><code>query = `SELECT laboratorio_id, lab_razao_social FROM laboratorio
              WHERE laboratorio_id IN (:fornecedores)`;
  params.fornecedores = fornecedores;
  
  var laboratorios = await sequelize.query(query, {
      type: QueryTypes.SELECT,
      replacements: params
  }).catch(err =&gt; {
      ...
  });
  </code></pre>
  <p>I managed to solve the problem casting both values to int using <code>parseInt</code>:</p>
  <pre><code>laboratorios.some(laboratorio =&gt; {
      const test1 = parseInt(venda.fornecedor)
      const test2 = parseInt(laboratorio.laboratorio_id)
      console.log(test1, typeof test1)
      console.log(test2, typeof test2)
      console.log(test1 == test2)
      if (test1 == test2){
          lab = laboratorio.lab_razao_social
          return true;
      }
      return false;
  });
  </code></pre>
  <p>But still, why they were returning <code>false</code> in first place?</p>
  <p>It makes no sense, since js would accept <code>string == int</code> and <code>float == int</code> if the values were the same. They are both integers, so there's no decimal cases, and if it was the case, console.log would shows decimal cases if there was any.</p>
  <p>Edit:</p>
  <p>The entire function for reference, the above code was just the parts I thought were relevant, but maybe there's something else:</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>async function graficoVenda(data, session, agrupamento){
      if('dataInicio' in data) {
          dataInicio = data.dataInicio;
          dataFim = data.dataFim;
      } else {
          dataInicio = moment().startOf('month').format('YYYY-MM-DD');
          dataFim = moment().endOf('month').format('YYYY-MM-DD');
      }
  
      params = {dataInicio: dataInicio, dataFim: dataFim};
  
      if (agrupamento == 'categoria') {
          let query = `SELECT COALESCE(NULLIF(itens.produto_tipo,''), 'SEM CATEGORIA') AS categoria,
                      SUM(itens.valor_total) AS total,
                      SUM(itens.quantidade) AS qtd,
                          ARRAY(SELECT AS STRUCT ROUND(SUM(itens.valor_total), 2) AS total_devolucao,
                          SUM(itens.quantidade) AS qtd_und_devolucao,
                          COALESCE(NULLIF(itens.produto_tipo,''), 'SEM CATEGORIA') AS categoria
                          from ${table},
                          UNNEST(itens) AS itens
                          WHERE rn = 1
                          AND data &gt;= @dataInicio AND data &lt;= @dataFim AND itens.situacao = 'DEVOLUCAO'
                          GROUP BY itens.produto_tipo ORDER BY total_devolucao DESC) AS devolucao
                      from ${table},
                      UNNEST(itens) AS itens
                      WHERE rn = 1
                      AND pedido.data &gt;= @dataInicio
                      AND pedido.data &lt;= @dataFim
                      AND pedido.situacao = 'CONFIRMADO'
                      AND itens.situacao = 'CONFIRMADO'`;
          [query,params] = FiltroEmpresa.filtroPedido(session, query, params);
          query += ` GROUP BY itens.produto_tipo ORDER BY total DESC`;
          const options = {
              query: query + `;`,
              params: params,
          };
          var [vendas] = await bigqueryClient.query(options).catch(err =&gt; {
              messages = err.errors.map(error =&gt; { return error.message; });
              throw new Error("Ocorreu um erro de banco de dados: "+messages.join(". ")+".");
          });
          const { devolucao } = vendas[0];
          var categoriaDevolucao = devolucao.map(venda =&gt; venda.categoria);
          var categorias = [];
  
          vendas.forEach(function(venda, index){
              let total, qtd;
              if(categoriaDevolucao.includes(venda.categoria)){
                  total = Math.round((venda.total - devolucao[categoriaDevolucao.indexOf(venda.categoria)]['total_devolucao']) * 100) / 100
                  qtd = venda.qtd - devolucao[categoriaDevolucao.indexOf(venda.categoria)]['qtd_und_devolucao']
                  retorno = {nome: venda.categoria, total: total, qtd: qtd}
              } else{
                  retorno = {nome: venda.categoria, total: Math.round(venda.total * 100) / 100, qtd: venda.qtd}
              }
              categorias[index] = retorno;
          });
          return categorias;
      } else if (agrupamento == 'fornecedor'){
          let query = `SELECT itens.laboratorio_id AS fornecedor,
                      SUM(itens.valor_total) AS total,
                      SUM(itens.quantidade) AS qtd,
                          ARRAY(SELECT AS STRUCT ROUND(SUM(itens.valor_total), 2) AS total_devolucao,
                          SUM(itens.quantidade) AS qtd_und_devolucao,
                          itens.laboratorio_id AS fornecedor
                          from ${table},
                          UNNEST(itens) AS itens
                          WHERE rn = 1
                          AND data &gt;= @dataInicio AND data &lt;= @dataFim AND itens.situacao = 'DEVOLUCAO'
                          GROUP BY itens.laboratorio_id ORDER BY total_devolucao DESC) AS devolucao
                      from ${table},
                      UNNEST(itens) AS itens
                      WHERE rn = 1
                      AND pedido.data &gt;= @dataInicio
                      AND pedido.data &lt;= @dataFim
                      AND pedido.situacao = 'CONFIRMADO'
                      AND itens.situacao = 'CONFIRMADO'`;
          [query,params] = FiltroEmpresa.filtroPedido(session, query, params);
          const options = {
              query: query + ` GROUP BY itens.laboratorio_id ORDER BY total DESC;`,
              params: params,
          };
          var [vendas] = await bigqueryClient.query(options).catch(err =&gt; {
              messages = err.errors.map(error =&gt; { return error.message; });
              throw new Error("Ocorreu um erro de banco de dados: "+messages.join(". ")+".");
          });
  
          if (vendas){
              var fornecedores = [];
              vendas.forEach(function(venda){
                  fornecedores.push(venda.fornecedor)
              });
      
              query = `SELECT laboratorio_id, lab_razao_social FROM laboratorio
                          WHERE laboratorio_id IN (:fornecedores)`;
              params.fornecedores = fornecedores;
      
              var laboratorios = await sequelize.query(query, {
                  type: QueryTypes.SELECT,
                  replacements: params
              }).catch(err =&gt; {
                  throw new Error("Ocorreu um erro de banco de dados: "+err.original.sqlMessage);
              });
      
              forn = [];
              const { devolucao } = vendas[0]
              var fornecedorDevolucao = devolucao.map(venda =&gt; venda.fornecedor);
              vendas.forEach(function(venda, index){
                  let total, qtd;
                  if(fornecedorDevolucao.includes(venda.fornecedor)){
                      total = Math.round((venda.total - devolucao[fornecedorDevolucao.indexOf(venda.fornecedor)]['total_devolucao']) * 100) / 100
                      qtd = venda.qtd - devolucao[fornecedorDevolucao.indexOf(venda.fornecedor)]['qtd_und_devolucao']
                      retorno = {total: total, qtd: qtd}
                  } else{
                      retorno = {total: Math.round(venda.total * 100) / 100, qtd: venda.qtd}
                  }
                  let lab = "";
                  laboratorios.some(laboratorio =&gt; {
                      const aux1 = parseInt(venda.fornecedor)
                      const aux2 = parseInt(laboratorio.laboratorio_id)
                      if (aux1 == aux2){
                          lab = laboratorio.lab_razao_social
                          return true;
                      }
                      return false;
                  });
                  retorno['nome'] = lab
                  forn[index] = retorno;
              });
              return forn;
          }
          return [];
      }
      return false;
  }</code></pre>
  </div>
  </div>
  </p>