Skip to content

Instantly share code, notes, and snippets.

@mojaray2k
Created August 25, 2018 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mojaray2k/a8eb2622d5595edd32b6f5fdacd0eb57 to your computer and use it in GitHub Desktop.
Save mojaray2k/a8eb2622d5595edd32b6f5fdacd0eb57 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/diqumox
/** Default Function Arguments */
// Example #1
function makeAjaxRequest(url, method = 'GET') {
return method;
}
console.log(makeAjaxRequest('google.com'));
// Example #2
function User(id) {
this.id = id;
}
function genereateId () {
return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);
}
function createAdminUser(user = new User(genereateId())) {
user.admin = true;
return user;
}
function addOffset(style = {offset: '10px'}) {
return style;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment