I am doing code archeology (digging up someone else's code) and I see the use of two vertical bars in what appears to be a bitwise operator. Can't find any explanation of this on the web and my experiemt below doesn't really explain it all. The code I dug up looks like this:
My experiments:
JavaScript:
answer = (ScriptThatMightReturnTRUE) || (ScriptThatReturnsString);
My experiments:
JavaScript:
<!DOCTYPE html>
<html>
<body>
<p>difference between a single vs double "|"?.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = [u]true | 5[/u];} [b]// prints 5[/b]
</script>
</body>
</html>
JavaScript:
document.getElementById("demo").innerHTML = [u]false | true[/u]; [b]// prints 1[/b]
document.getElementById("demo").innerHTML = [u]"fred" | false[/u]; [b]// prints 0[/b]
document.getElementById("demo").innerHTML = [u]"fred" | true[/u]; [b]// prints 1[/b]
document.getElementById("demo").innerHTML = [u]true || 5[/u]; [b]// prints true[/b]
document.getElementById("demo").innerHTML = [u]5 || true[/u] ; [b]// prints 5[/b]
document.getElementById("demo").innerHTML = [u]false || true[/u] ; [b]// prints true[/b]
document.getElementById("demo").innerHTML = [u]true || false[/u] ; [b]// prints true[/b]