Skip to content

Instantly share code, notes, and snippets.

@mitsuru793
Last active December 2, 2015 04: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 mitsuru793/e1174219581960298c91 to your computer and use it in GitHub Desktop.
Save mitsuru793/e1174219581960298c91 to your computer and use it in GitHub Desktop.
JavaScriptでreturn文がないとどうなるのか?
// 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