Skip to content

Instantly share code, notes, and snippets.

View UltCombo's full-sized avatar

Fabricio Matte UltCombo

View GitHub Profile
1 ^ 1 === 0 //checkada (1) é == 1 então retorna 0
0 ^ 1 === 1 //não checkada (0) é != 1 então retorna 1
input.checked = 0;
input.checked = false;
input.checked = 1 ^ 1; //1 e 1 são iguais (não me diga?)
input.checked = 0;
var input = $('input')[0];
input.checked = input.checked ^ 1;
$('input')[0].checked ^= 1;
input.checked = input.checked ^ 1;
input.checked = true ^ 1; //converte implicitamente true para 1; false para 0
input.checked = 1 ^ 1;
@UltCombo
UltCombo / gist:5359288
Created April 10, 2013 23:16
XOR truth table
^ | 0 1
--+-----
0 | 0 1
1 | 1 0
<<< +true
>>> 1
<<< +false
<<< 0
>>> !!1
<<< true
>>> !!0
<<< false
>>> 1 == true
<<< true
>>> 0 == false
<<< true
[] == false //ToPrimitive deste array retorna string vazia
"" == false //comparação com boolean converte booleano ToNumber
"" == 0 //comparação de string com número converte string ToNumber
0 == 0
true