Skip to content

Instantly share code, notes, and snippets.

@shahab570
Last active December 30, 2020 03:21
Show Gist options
  • Save shahab570/1456215a8710b5068554ca269e039e9e to your computer and use it in GitHub Desktop.
Save shahab570/1456215a8710b5068554ca269e039e9e to your computer and use it in GitHub Desktop.
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