formations/javascript/base/structures-2.md

662 B

.cadoles-slide-title[Structures de contrôle (2/3)]

Tests, transitivité, égalité stricte et petites subtilités

var test;

test = 1 == '1';            // -> true
test = 1 === '1';           // -> false

test = 0 == false;          // -> true
test = 0 === false;         // -> false

test = 1 == true;           // -> true
test = 1 === true;          // -> false

test = '' == false;         // -> true
test = '' === false;        // -> false

test = [] == false;         // -> true
test = [] === false;        // -> false

test = undefined == null;   // -> true
test = undefined == false;  // -> false
test = NaN == NaN;          // -> false