Skip to content

Instantly share code, notes, and snippets.

@thamizhchelvan
Created December 10, 2017 13:35
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 thamizhchelvan/c7c73bfa64a73fc93dfe6fc9cc4cbfea to your computer and use it in GitHub Desktop.
Save thamizhchelvan/c7c73bfa64a73fc93dfe6fc9cc4cbfea to your computer and use it in GitHub Desktop.
The comma operator
//The comma operator is useful to execute series ouf expressions
function print_hello(){
console.log('Hello');
return 'Hello';
}
function print_world(){
console.log('World');
return 'World';
}
function print_js(){
console.log('JavaScript');
return 'JavaScript';
}
var output = (print_hello(),print_world(),print_js());
/*
Above code prints
Hello
World
JavaScript
and returns JavaScript to variable output
*/
console.log(output); //prints JavaScript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment