Skip to main content
added 201 characters in body
Source Link
trusktr
  • 46k
  • 58
  • 215
  • 289

I find this to be the simplest, most readable way:

if (typeof myVariable === 'undefined') { myVariable = 'default'; }
//use myVariable here

Paul Dixon's answer (in my humble opinion) is less readable. Why not just keep than this, but it simple?comes down to preference.

insin's answer is much more complicatedadvanced, but much more functionaluseful for big functions!

EDIT 11/17/2013 9:33pm: I've created a package for Node.js that makes it easier to "overload" functions (methods) called parametric.

I find this to be the simplest, most readable way:

if (typeof myVariable === 'undefined') { myVariable = 'default'; }
//use myVariable here

Paul Dixon's answer (in my humble opinion) is less readable. Why not just keep it simple?

insin's answer is much more complicated, but much more functional for big functions!

I find this to be the simplest, most readable way:

if (typeof myVariable === 'undefined') { myVariable = 'default'; }
//use myVariable here

Paul Dixon's answer (in my humble opinion) is less readable than this, but it comes down to preference.

insin's answer is much more advanced, but much more useful for big functions!

EDIT 11/17/2013 9:33pm: I've created a package for Node.js that makes it easier to "overload" functions (methods) called parametric.

deleted 29 characters in body
Source Link
trusktr
  • 46k
  • 58
  • 215
  • 289

I find this to be the simplest, most readable way:

if (typeof myVariable ===== undefined'undefined') { myVariable = 'default'; }
//use myVariable here

I don't see why you'd want to use the method in Paul Dixon's answer compared to this one(in my humble opinion) is less readable. Why not just keep it simple?

insin's answer is much more complicated, but much more functional for big functions!

I find this to be the simplest, most readable way:

if (typeof myVariable == undefined) { myVariable = 'default'; }
//use myVariable here

I don't see why you'd want to use the method in Paul Dixon's answer compared to this one. Why not just keep it simple?

insin's answer is much more complicated, but much more functional for big functions!

I find this to be the simplest, most readable way:

if (typeof myVariable === 'undefined') { myVariable = 'default'; }
//use myVariable here

Paul Dixon's answer (in my humble opinion) is less readable. Why not just keep it simple?

insin's answer is much more complicated, but much more functional for big functions!

Source Link
trusktr
  • 46k
  • 58
  • 215
  • 289

I find this to be the simplest, most readable way:

if (typeof myVariable == undefined) { myVariable = 'default'; }
//use myVariable here

I don't see why you'd want to use the method in Paul Dixon's answer compared to this one. Why not just keep it simple?

insin's answer is much more complicated, but much more functional for big functions!