Last active
December 30, 2020 03:21
-
-
Save shahab570/1456215a8710b5068554ca269e039e9e 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
function abc(x,y) { | |
//we used logical OR(||) operator. It returns the first truthy value. | |
//if first value is undefined, second value is returned | |
x = x || 100; | |
// value of x is x which is given at the function call. If not given value is 100 | |
y = y || 50; | |
// value of y is y which is given at the function call. If not given value is 50 | |
console.log(x,y); | |
} | |
abc(); // 100 50 | |
abc(5) // 5 50 | |
abc(5,10) // 5 10 | |
abc(0,0) // 100 50 | |
abc (null,null) // 100 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment