Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Mandatory Parameter Shorthand javascript

// Mandatory Parameter Shorthand
// Longhand:
function foo(bar) {
  if(bar === undefined) {
    return ('Missing parameter!');
  }
  return bar;
}
console.log(foo());


// Shorthand:
mandatory = () => {
  return ('Missing parameter!');
}
foo_ = (bar = mandatory()) => {
  return bar;
}
console.log(foo_());
 
PREVIOUS NEXT
Tagged: #Mandatory #Parameter #Shorthand #javascript
ADD COMMENT
Topic
Name
7+3 =