Created
January 25, 2018 00:10
-
-
Save jw-jenrise/b63cee286e40eda862c26d6aeee07732 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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