+ 2
what's the difference between null and undefined values in JavaScript
what's the difference between null and undefined values in JavaScript, and please i need an code example of both of them, so i'll understand
3 Antworten
+ 1
This is a great question in JS.
These things👇 helps while trying to fiddle and understand undefined and null.
- Doing equality comparisons.
- Using typeof operator
- scope analysis
- Type coercion behavior ( Ex. both are falsy values in Boolean)
BUT here's the main difference.
We set null ourselves to imply that there's no value there.
But undefined mostly stays by default.
Here's a quick code that might help.
https://sololearn.com/compiler-playground/WWEd43DDYFGZ/?ref=app
+ 4
<BernieByte>
The following threads might help you:-
https://www.sololearn.com/Discuss/1772843/?ref=app
https://www.sololearn.com/Discuss/3067338/?ref=app
+ 3
Hi <BernieByte> the Q&A Search feature can sometimes help you find your answer. It is usually quicker than waiting for someone to respond to your post. I found that this question was asked before. You may find your answer here:
https://www.sololearn.com/Discuss/3067338/?ref=app