What is the difference between a variable with an empty string and a variable with a value of undefined? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the difference between a variable with an empty string and a variable with a value of undefined?

Is var empty= " "; == var empty;?

25th May 2020, 7:12 AM
Volca-Nick Mukuha
Volca-Nick Mukuha - avatar
1 Answer
+ 1
No, it's not the same. If you declared a variable, you only reserve some memory (as much as required, depending on the data type) for later use. If you assign an empty string, it has a concrete value, which is stored within the reserved memory. You could learn some C for better understanding.
25th May 2020, 3:08 PM
Sandra Meyer
Sandra Meyer - avatar