Default value for javascript function


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function foo(a, b)
  2. {
  3. a = typeof(a) != 'undefined' ? a : 42;
  4. b = typeof(b) != 'undefined' ? b : 'default_b';
  5. //...
  6. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.