Introduction
In this article we will learn how to check the value is undefined or null in javascript. Maintain your code in a good manner to avoid undefined issue. We already talked about the difference between null and undefined.
Previous Updates
In previous articles we have learnt Transaction Commit and Rollback in sql server with example.What is Lock and how to achieve lock on sql table. Authorization in Asp.Net. How high quality content affects your Website. What is Blocking and Deadlock In SQL. Top 30 Asp.net interview question. What is the difference between null and undefined.
How do i check for null and undefined
There is no big code and complexity to check null and undefined in javascript.
Check for null
if (a == null)
|
if (a === null)
|
Check for undefined
if (typeof a === "undefined")
|
if (a === "undefined")
|
Or
if (a == "undefined")
|
Check for null and undefined using same code
if (!a) {
// a will be
false for null , undefined as wll as for empty string "".
}
|
Difference Between null and undefined in Javascript. Read more
0 comments:
Post a Comment