--- title: function* expression slug: Web/JavaScript/Reference/Operatörler/function* translation_of: Web/JavaScript/Reference/Operators/function* ---
The function* keyword can be used to define a generator function inside an expression.
function* [name]([param1[, param2[, ..., paramN]]]) {
statements
}
nameparamNstatementsA function* expression is very similar to and has almost the same syntax as a {{jsxref('Statements/function*', 'function* statement')}}. The main difference between a function* expression and a function* statement is the function name, which can be omitted in function* expressions to create anonymous generator functions. See also the chapter about functions for more information.
Aşağıdaki adlandırılmamış fonksiyondur ve gelen değer karesini verir.
var x = function*(y) {
yield y * y;
};
| Specification | Status | Comment |
|---|---|---|
| {{SpecName('ES2015', '#', 'function*')}} | {{Spec2('ES2015')}} | Initial definition. |
| {{SpecName('ESDraft', '#', 'function*')}} | {{Spec2('ESDraft')}} |
{{Compat("javascript.operators.function_star")}}