Baseline Widely available
GeneratorFunction
ìì±ìë ìë¡ì´ generator function
ê°ì²´ë¥¼ ìì±íë¤. JavaScript ìì 모ë generator function ì ì¤ì ë¡ GeneratorFunction
object ì´ë¤.
주ìí ì ì, GeneratorFunction
ì´ ì ì ê°ì²´(global object)ê° ìëë ì ì´ë¤. GeneratorFunctionì ë¤ìì ì½ë를 ì¤íí´ì ì»ì ì ìë¤.
Object.getPrototypeOf(function* () {}).constructor;
Syntax
new Function(arg1, functionBody)
new Function(arg1, arg2, functionBody)
new Function(arg1, ... , argN, functionBody)
Parameters
arg1, arg2, ... argN
ì´ í¨ììì ê³µìì ì¸ argument ì´ë¦ë¤ë¡ ì¬ì©ëë ì´ë¦ë¤ì´ë¤. ê°ê°ì ì í¨í Javascript ìë³ìì´ê±°ë ì¼íë¡ êµ¬ë¶ë 문ìì´ ë¦¬ì¤í¸ì í´ë¹ëë 문ìì´ì´ì´ì¼ íë¤; for example "x
", "theValue
", or "a,b
".
functionBody
í¨ì ì ì를 구ì±íë JavaScript ë¬¸ì´ í¬í¨ë 문ìì´.
GeneratorFunction
ìì±ìë¡ ìì±ë generator function
ê°ì²´ë ê·¸ í¨ìê° ìì±ë ë ë¶ìíë¤. ì´ë¬í í¨ìë¤ì´ ëë¨¸ì§ ì½ëë¤ê³¼ í¨ê» ë¶ìë기 ë문ì, function* expression
ì¼ë¡ generator functionì ì ì¸íê³ ì½ë ë´ìì í¸ì¶íë ê²ë³´ë¤ ë í¨ì¨ì ì
ëë¤.
ê·¸ í¨ìë¡ ì ë¬ë 모ë argumentsë ìì±ë í¨ì ììì íë¼ë¯¸í°ì ìë³ì ì´ë¦ì¼ë¡ ê·¸ê²ë¤ì´ ì ë¬ë ììëë¡ ì²ë¦¬ëë¤.
ì°¸ê³ :
generator function
created with theGeneratorFunction
constructor do not create closures to their creation contexts; they always are created in the global scope. When running them, they will only be able to access their own local variables and global ones, not the ones from the scope in which theGeneratorFunction
constructor was called. This is different from usingeval
with code for a generator function expression.
new ìì´ GeneratorFunction
ìì±ì를 í¨ìì²ë¼ ì¬ì©íë ê²ì ìì±ìì²ë¼ ì¬ì©íë ê²ê³¼ ëì¼í í¨ê³¼ë¥¼ ê°ëë¤.
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
var g = new GeneratorFunction("a", "yield a * 2");
var iterator = g(10);
console.log(iterator.next().value); // 20
ëª
ì¸ì ë¸ë¼ì°ì í¸íì± See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4