Skip to content

Instantly share code, notes, and snippets.

@jw-jenrise
Created January 25, 2018 00:10
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 jw-jenrise/b63cee286e40eda862c26d6aeee07732 to your computer and use it in GitHub Desktop.
Save jw-jenrise/b63cee286e40eda862c26d6aeee07732 to your computer and use it in GitHub Desktop.
console.log("Begin example - 5");
// Adding of three numbers using a function
// Define an add function
function add(a,b,c){
return a + b + c;
}
// EXTRA ARGUMENT IS IGNORED
var e = add(1,2,3,4);
console.log("Result =" + e); // The extra argument in the call is ignored
// ARGUMENTS NOT SUPPLIED BECOMES UNDEFINED
var f = add(1,1);
console.log("Result =" + f);
// Notes for the add(1,1)
// The last parameter becomes undefined as it is not sent.
// becomes var f = add(1,1,undefined);
// at the function,
// the return a + b + c
// becomes
// return 1 + 1 + undefined
// which results as NaN ( any number + undefined = NaN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment