Difference between "==" and "=="

Asked

Viewed 75 times

0

I was developing a code javascript and I saw that the compiler accused error in the equality that I did at that time, but there was no error in the execution.

I would like to know the difference of equality "==" and "==" javascript?

inserir a descrição da imagem aqui

  • @Victor check this post, has information that describes well the difference between "==", "===" and Object.is https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Igualdade ---------------------------- "=": equal to; "===" : equal value and type; x === 5 true x === "5" false

  • 3

    Duplicate https://answall.com/questions/280978/os-operatorss-e-podem-considerador-de-l%C3%B3gica-difusa

1 answer

2


In javascript: == does not take the type of the variable into account, whereas the === takes the type of variable into account

See some examples:

var verdadeiro = '1' == 1;
var falso = '1' === 1;


var var1 = 'true' == true;                 // false
var var2 = '0' == false;                   // true
var var3 = null == undefined;              // true
var var4 = false == null;                  // false
var var5 = null == 0;                      // false
var var6 = '' == 0;                        // true
var var7 = '\t\n' == 0;                    // true
var var8 = '1' == true;                    // true

Browser other questions tagged

You are not signed in. Login or sign up in order to post.