1

I cannot grasp an idea of undefined. I know what undefined is, I know what null is but what's the point of having undefined? Obviously, coming from another language where if the variable is not used it's pointing to a dummy location in memory aka null. If the variable is not assigned any value, it gets assigned null until you assign another value to it. However, I cannot understand what is the purpose of undefined in JS if null exist. Thank you in advance.

Alex
  • 53
  • 4
  • these responses may be helpful https://softwareengineering.stackexchange.com/questions/101107/what-exactly-undefined-means-in-javascript-why-its-there-what-usages-it-has – Stuart Apr 06 '21 at 18:58
  • Also this answer: https://stackoverflow.com/a/463608/567595 – Stuart Apr 06 '21 at 19:00
  • I have a related answer here: https://stackoverflow.com/a/37980662/2079345 – chiliNUT Apr 06 '21 at 19:04
  • From the specification: [_“null value: primitive value that represents the intentional absence of any object value”_](https://tc39.es/ecma262/#sec-null-value), [_“undefined value: primitive value used when a variable has not been assigned a value”_](https://tc39.es/ecma262/#sec-undefined-value), but it’s also used as the return value of a function that doesn’t return anything, or the result of the completion record of various declarations, etc. – Sebastian Simon Apr 07 '21 at 02:31

0 Answers0