Skip to content
Advertisement

How can I check if vars are equal 0? [closed]

On php documentation we can see:

JavaScript

If I have for example $var1 = 0; and $var2 = 0; on php I can do:

JavaScript

But I cant do this:

JavaScript

How can I do for check if the two vars are equal to 0 on the same if?

Advertisement

Answer

You can run

JavaScript

to see if those two variable are both holding the integer zero.

If you want a more loose type check (see if the variables are zero, or false, or null, for example), you can do:

JavaScript

If (based on your question) you wanted to see if the variable holds the string "0", you would do it like this:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement