Lambda function syntax in JavaScript without curly braces

后端 未结 2 596
梦谈多话
梦谈多话 2020-12-03 22:08

I just found out that the following (awesome) syntax is accepted by Firefox

f = function(x) x+1;
f(17) //gives 18

Does anyone know what the

2条回答
  •  -上瘾入骨i
    2020-12-03 22:29

    This isn't part of a standard. The documentation is at https://developer.mozilla.org/en/New_in_JavaScript_1.8#Expression_closures_%28Merge_into_own_page.2fsection%29

    There's discussion about adding some syntax along these lines or even shorter to the standard. See http://wiki.ecmascript.org/doku.php?id=strawman:shorter_function_syntax

提交回复
热议问题