Search code examples
javascriptoperators

What does ||| mean in JavaScript?


I've googled this and searched through the JavaScript documentation but I can't find any mention of this operator: a |ǀ| b

When I try the operator on its own I get an error but when I run the following code it runs perfectly fine:

var a, b = 0; tex = '\u0076\u0061r'
var players, score = 0, x, y, z = 1;
function f(s) {
	var t = 0, r = 0;
    var js = 'window';
    while (t == r) {
    	if (t == 1) {
        	r = s.length;
            return false;
        } else {
        	t += 1;
        }  for (var i = 0; i < 20; i++) {
        	r = 20;i+=9000;eval(s); x = 50; y =+ 8;
            z = -20; y = s;
        }
        if (r < 20) {
        	return t + 2;
        }}
	    return true;
	} while (f(tex + ' \u01C0='+'0') && score < 900) {
	score = 9000.0001;}eval(y); a = 1; b += a;
	x = 50;{y =+ 8;
}

// testing:
document.writeln(false |ǀ| false); // 0
document.writeln(false |ǀ| true);  // 1
document.writeln(true  |ǀ| false); // 1
document.writeln(true  |ǀ| true);  // 1

Changing the values of a and b would suggest it works like || but I just can't work out why it works with the previous code, but doesn't work on its own. Does anyone know whats going on here?


Solution

  • It's not an operator. It's the | operator, twice, with a "Latin letter 'Dental Click'" character in between. That character is valid in JavaScript identifiers. Thus the expression:

    false |ǀ| false
    

    (probably) means the same thing as

    false | undefined | false
    

    because there's no real variable called ǀ. (edit — Actually there probably is, otherwise you'd get a reference error.)

    The | (bitwise-OR) operator treats its operands as numbers, and both false and undefined become 0.

    That function f() is what's defining a window property called ǀ.