Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

difference between undefined and null javascript

undefined: It means a variable declared, but no value has been assigned a value.

//example: 
var demo;
alert(demo); //shows undefined
alert(typeof demo); //shows undefined

null: Whereas, null in JavaScript is an assignment value. 
You can assign it to a variable.

//Example: 
var demo = null;
alert(demo); //shows null
alert(typeof demo); //shows object
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #difference #undefined #null #javascript
ADD COMMENT
Topic
Name
7+7 =