182 reputation
7
bio website
location NYC
age 25
visits member for 3 years, 1 month
seen Nov 25 at 17:48

Computer Scientist / Comedian


Sep
24
awarded  Autobiographer
Nov
25
accepted Initializing a variable as undefined
Nov
25
awarded  Commentator
Nov
25
comment Initializing a variable as undefined
are there any merits to doing this in javascript?
Nov
22
comment Initializing a variable as undefined
What do you mean by null is a valid value? I can think of an example where checking for undefined isn't clear: imagine if you set this.foo and this.bar to undefined. If I, a new developer to your project, try to evaluate this.baz, it will return undefined just like this.bar and this.foo. I have no way of distinguishing between what properties have been initialized and which ones simply don't exist.
Nov
20
comment Initializing a variable as undefined
@MattFenwick does "use strict" turn undefined variable use into an error? This project is not in strict mode- should it be? I am indeed familiar with hoisting and know that variable definitions are hoisted to the top of their scope and initialized as undefined- but is there any reason a human would write that?
Nov
20
comment Initializing a variable as undefined
@StevenBurnap Right- and in that case my question is why not use null? null is explicit AND doesn't carry the same confusion that undefined does. undefined is the result of trying to access a nonexistant object member, so a programmer trying to debug would see that this.prop is undefined, and might think that that property is nonexistant. Were this.prop null however, the developer would see that the object member existed.
Nov
20
comment Initializing a variable as undefined
@StevenBurnap right- wouldn't var foo; do the same thing though?
Nov
20
asked Initializing a variable as undefined
Feb
25
awarded  Caucus
May
24
comment What is the name for a NON-self-calling function?
I believe you're referring to Immediately Invoked Function Expressions (not self-calling functions) benalman.com/news/2010/11/…
Mar
30
accepted What's the best way to comment in a code review?
Mar
29
awarded  Critic
Mar
29
asked What's the best way to comment in a code review?
Mar
27
accepted Is application-specific data required for good unit testing?
Mar
27
awarded  Student
Mar
27
asked Is application-specific data required for good unit testing?
Dec
12
awarded  Supporter
Nov
8
awarded  Scholar
Nov
8
accepted Best practice for populating a dynamic popup menu?