Javascript is very flexible with regards to checking for "null" values. I'm guessing you're actually looking for empty strings, in which case this simpler code will work:
if(!pass || !cpass || !email || !cemail || !user){
Which will check for empty strings (""
), null
, undefined
, false
and the numbers 0
and NaN
Please note that if you are specifically checking for numbers it is a common mistake to miss 0
with this method, and num !== 0
is preferred (or num !== -1
or ~num
(hacky code that also checks against -1
)) for functions that return -1
, e.g. indexOf
)
null acts as a number and object at the same time. Comparing null >= 0 or null <= 0 results in true . Comparing null === 0 or null > ...
There are 6 types of objects: Object; Date; Array; String; Number; Boolean. And 2 data types that cannot contain values: null; undefined ...
In JavaScript, null is a special value that represents an empty or unknown value. For example, let number = null;. The code above suggests that the number ...
JavaScript typeof, null, 和undefined typeof 操作符你可以使用typeof 操作符来检测变量的数据类型。 实例typeof 'John' &..