Javascript closures function parameters?

后端 未结 3 1564
不思量自难忘°
不思量自难忘° 2021-02-09 02:47

Code belongs to javascriptissexy.com My question is why invoking mjName (\"Jackson\") returns \"This celebrity is Michael Jackson\"? Is it that second parameter given in ANY out

3条回答
  •  伪装坚强ぢ
    2021-02-09 03:39

    The function is evaluated to be celebrityName ("Michael")("Jackson");

    Steps :

    1. celebrityName ("Michael") returns function lastName(theLastName)
    2. ("Jackson") is passed to function lastName
    3. function lastName(theLastName) prints the string when executed

    Arguments from left to right go from outer to inner called methods.

提交回复
热议问题