Posted By

housecor on 09/23/10


Tagged

default parameters arguments


Versions (?)

Default parameters


 / Published in: JavaScript
 

This sets b to 3 if b isn\'t passed. So all params all optional.

  1. function testDef(a, b) {
  2. b = b || 3;
  3. return b;
  4. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: flow on October 3, 2010

u can also do it like this: !b && (b = 3);

You need to login to post a comment.