Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save juanlopezdev/1b84115f1254be8890be to your computer and use it in GitHub Desktop.
Save juanlopezdev/1b84115f1254be8890be to your computer and use it in GitHub Desktop.
Inicializar variables en una funcion en "Javascript"
function myfunction(param) {
return (param === undefined) ? true : param;
}
/* Testing 'myfunction' in console..
// Default value example
> myfunction();
true
> myfunction('Hello world !');
"Hello world !"
> myfunction('');
""
> myfunction(123456);
123456
> myfunction(null);
null
> myfunction(false);
false
> myfunction(true);
true
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment