Last active
August 29, 2015 14:06
-
-
Save aaronfrost/d815545ccf196e0bf07c to your computer and use it in GitHub Desktop.
Do I Call This "Undeclared"?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a; | |
console.log(a); //Logs 'undefined' | |
console.log(b); //ReferenceError: 'b' is not defined | |
/** | |
* Neither are defined, but only the undeclared variable gets an 'undefined' error. | |
* | |
* So, is the correct idiom 'undeclared' when referring to an instruction that will throw | |
* a ReferenceError because it wasn`t declared? Or is there another idiom that I should use? | |
* | |
* I have heard people say "There is no 'undeclared' in JavaScript", so I am not sure what to call it. | |
* | |
* What Say Ye? | |
* / |
I'm not a deep JS developer but I would personallycall it 'unknown'.
Here's why. It hasnt been defined what it isAND what its value is. Undeclared to me implies there is data but you just dont know the type (internally) yet.
In this case both scenarios are gone, if you assigned b to some crazy 'thing' that JavaScript doesn't understand wtf is going on, you may consider undeclared.... But what the heck do I know
If there is documentation out there referring to undeclared, ive never seen it so tgose are my opinions solely based on what i see in front of me.
$.02
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have always used
undeclared
to describe this.Straight from MDN:
From that I consider
a
declared as a variable, but with an undefined value. Ergob
would be undeclared.