Created
July 10, 2015 06:07
-
-
Save cod3beat/e8e406eeec1ed185b067 to your computer and use it in GitHub Desktop.
Manfaat dari return
This file contains hidden or 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 melakukanSesuatu(a, b) { | |
var c = a + b; | |
// nah, bagaimana agar konteks di luar melakukanSesuatu | |
// dapat memperoleh nilai c? | |
// kita gunakan `return` | |
// sehingga konteks yang menjalankan `melakukanSesuatu` | |
// akan memperoleh nilai `c` ini | |
return c; | |
} | |
var hasil = melakukanSesuatu(10, 2); | |
console.log(hasil); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment