if (obj == null)
What do we expect to check by using the above condition in javascript?
javascript never sets a value to null. So we can check only whether we have assigned null programmatically by using the above condition. In most of the programming languages if we want to check whether a values has been assigned to a variable or not we can use the above condition(C# as an example) but not in javascript. When a value is not assigned to a variable in javascript, it assigns the default value of 'undefined'. So check undefined.
if(typeof obj == 'undefined')
No comments:
Post a Comment