In JavaScript !foo is a boolean toggle so if foo = true; then !foo is checking to see if foo equals the opposite value in this case false,
your function:
if (a !b)
{
// something here
}
doesn’t do anything, and should actually just be:
if (!b)
{
// something here
}
which tests to see if bis in the opposite state.
When you use != you are comparing two values to see if one doesn’t equal to the other.
so your function:
if {a != b)
{
// something here
}
checks to see if a doesn’t equal b.
Cheers.
solved Difference Between ! and != in JavaScript [duplicate]