9 تغريدة 1 قراءة Apr 19, 2023
Difference between null and undefined in JavaScript 🚀
🧵👇
Don't forget to bookmarked it for future references...
✦ In JavaScript, null and undefined are special values that represent the absence of a value or object.
☆ undefined
• it's a property of the global object, and it is a value that is assigned to variables that have just been declared or to function arguments that have not been assigned a value.
• Example :
☆ null
• null is a value that can be assigned to a variable as a representation of no value.
• It is an explicit representation of the absence of a value.
• Example :
let y = null;
console.log(y); // Output: null
✦ It is important to note that null and undefined are not the same.
✦ undefined means a variable has been declared but has not been assigned a value, while null means a variable has been declared and has been assigned the value null explicitly.
✦ We can use the typeof operator to determine the type of a value.
✦ The typeof operator will return "undefined" for variables that are undefined and "object" for variables that are null.
✦ Example :
☆ Summary
• undefined represents the absence of a value, while null represents the absence of an object.
End thread 🧵
If this thread helpful for you then :
1. Do Retweet the FIRST TWEET.
2. Follow me and turn on the notifications: @personalvipin
Thank you ❤️

جاري تحميل الاقتراحات...