What is the difference between null and undefined?


Null and undefined in javascript:

Undefined: when you have declared any variable but you have not assigned any value then it will show undefined.

Var abc; 

If we will check the type of the variable abc then it will show Undefined. Means you have defined a variable but you can insert any type of value as an array, number, string, etc. because javascript is an auto casting when you have assigned any value in the variable.

Null: Means you have defined a variable and assigned a value as Null. Null is the blank container in the future will show your data as you can show any add banner: he represents that I am waiting for you.

If you want to check Null type then it will show as an object.

Var abc = null;

No comments:

Note: Only a member of this blog may post a comment.

Copyright Reserved to Anything Learn. Powered by Blogger.