Last active
August 29, 2015 14:25
-
-
Save Bambina-zz/58983700572ce4b358f9 to your computer and use it in GitHub Desktop.
js first-class object and first-class function
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
var x = function(){} //名前のない関数を生成し、変数xに代入している。 | |
var x = new Function("console.log('lalala')") //組み込み関数Functionから、console.logの処理を持つ無名関数を生成し、変数xに代入している。jsの全ての関数は組み込み関数Functionを継承する。 | |
x //=>function anonymous(){console.log('lalala')}を返す。 | |
x() //=>lalala undefined を返す。xに代入された無名関数を実行した。jsの全ての関数はデフォルトで値を返す仕様だが、返り値が定義されていない場合は、undefinedを返す。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment