Created
December 10, 2017 13:35
-
-
Save thamizhchelvan/c7c73bfa64a73fc93dfe6fc9cc4cbfea to your computer and use it in GitHub Desktop.
The comma operator
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
//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