Default parameters


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

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


Copy this code and paste it in your HTML
  1. function testDef(a, b) {
  2. b = b || 3;
  3. return b;
  4. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.