非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。
Obsolete since Gecko 60 (Firefox 60 / Thunderbird 60 / SeaMonkey 2.57)
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
Expression closures are a shorthand function syntax for writing simple functions.
function [name]([param1[, param2[, ..., paramN]]]) expression
name
paramN
The name of an argument to be passed to the function. A function can have up to 255 arguments.
expression
The expression which comprise the body of the function.
This addition is nothing more than a shorthand for writing simple functions, giving the language something similar to a typical Lambda notation .
JavaScript 1.7 and older:
function(x) { return x * x; }
JavaScript 1.8:
function(x) x * x
This syntax allows you to leave off the braces and 'return' statement - making them implicit. There is no added benefit to writing code in this manner, other than having it be syntactically shorter.
A shorthand for binding event listeners:
document.addEventListener('click', function() false, true);
Using this notation with some of the array functions from JavaScript 1.6:
elems.some(function(elem) elem.type == 'text');
Supported nowhere. Historically supported in Firefox 3 till 60.