Skip to content Skip to sidebar Skip to footer

How To Simulate A Nor Gate In Javascript?

Does anyone know a way to simulate a NOR-gate in JavaScript? https://en.wikipedia.org/wiki/NOR_gate From what I have seen so far the language has only AND and OR.

Solution 1:

well the easiest way : !(a || b)

Solution 2:

You can use a reversed && like so:

var a = false;
var b = false;

if ( !a && !b ) {
    // some code
}

Solution 3:

Always you could negate the logic or making something like this:

if(!(true || true))

this way you always going to obtain the or result negated, which really have a NOR-gate behavior.

Solution 4:

This is a NOT-AND gate which is equal to an AND gate followed by a NOT gate.

if(!(a && b)) { // code }

Solution 5:

Here's the bitwise version:

~(a | b)

Post a Comment for "How To Simulate A Nor Gate In Javascript?"