Last active
December 2, 2015 04:35
-
-
Save mitsuru793/e1174219581960298c91 to your computer and use it in GitHub Desktop.
JavaScriptでreturn文がないとどうなるのか?
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
// console.logのエイリアス | |
var l = function(x) { console.log(x) }; | |
function getWithReturn() { | |
return "Return"; | |
} | |
function getWithNotRetun() { | |
"NotRetun" | |
} | |
// CoffeeScriptのように最後の評価値が返ることはありません。 | |
// 戻り値が設定しないと、undefinedが返ります。 | |
l(getWithReturn()); // Return | |
l(getWithNotRetun()); // undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment