Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

.default in javascript

function multiply(a, b) {
  b = (typeof b !== 'undefined') ?  b : 1
  return a * b
}

multiply(5, 2)  // 10
multiply(5)     // 5
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #javascript
ADD COMMENT
Topic
Name
6+8 =