I have a object
var data = {1:undefined,2:null,3:10,4:""}
I want to replace all the undefined and null values by 0. I am using the following code to do that:
for (var index in data) {
    if (!data[index]) {
        data[index] = 0;
    }
}
Result I am expecting is :  {1:0,2:0,3:10:4:""} 
But Result is :  {1:0,2:0,3:10:4:0} because it is considering empty string as null. Is it known behavior ? 
I can check it by using 
(if(data[index] == undefined || data[index] == null)) 
But I wanted to know the behavior of the above solution.
 
     
     
    