I have attached jsfiddle example here. I want to know difference between null and blank
My function is working fine but when I change blank to null in if condition it stop working.
I have attached jsfiddle example here. I want to know difference between null and blank
My function is working fine but when I change blank to null in if condition it stop working.
""
) = value (but an empty one), null
= no value at all.
– sp00m
Commented
Aug 30, 2012 at 7:07
'' != null
.
– Blender
Commented
Aug 30, 2012 at 7:09
0
and null, one is an actual value 0
and null is "I have no value". You can add a number to 0
but you can't add a value to no value
.
– Joachim Isaksson
Commented
Aug 30, 2012 at 7:10
You have to pay attention to what ""
, null
, and undefined
, mean in javascript. It can lead to some misconception in boolean tests concerning values and types.
""
is the empty string which is used also as an empty property. A string object "" is defined and is not null.
null
is an object whose type is null. An object is said to be null when it has no other value/property (its type is null).
undefined
means that the object is not defined and the interpreter has no reference to it. undefined is not an object.
Some problems arises when you try to pare those values with false
. Try to have a look at the following examples.
Here are some reference links:
Tutorial on some type checking
A little more explanation
you should probably change the condition to if('input[type=radio]:checked').val())
this way it will check both null and empty strings. but in this case i dont think you will ever get a null string.
dont use "!="
here because that might lead to some unpredictable behaviour use "!=="
.
""
A NULL value represents the absence of a value for a record in a field.
An empty value is a value with no significant data in it.
Why an "empty character string" is different from a null value? Cause you're paring a string (with no characters inside) with a with a no data type value: they differ !