I’m facing some difficulty when dealing with null values in JavaScript. I have two cases in my JavaScript where the object can be null or can have some other value so I do this:
if(feild_values != null || typeof(feild_values) != 'null') {
alert(feild_values.id[i-1]);
}
However, Firebug gives me an error saying:
TypeError: feild_values is null alert(feild_values.id[i-1]);
How do I manage this?
Remove || typeof(feild_values) != ‘null’
You don’t need it and typeof(null) isn’t ‘null’, its ‘object’
Can simplify to: