Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 功能和功能的区别是什么*_Javascript_Function_Generator_Ecmascript 6_Ecmascript Harmony - Fatal编程技术网

Javascript 功能和功能的区别是什么*

Javascript 功能和功能的区别是什么*,javascript,function,generator,ecmascript-6,ecmascript-harmony,Javascript,Function,Generator,Ecmascript 6,Ecmascript Harmony,使用function和function创建的生成器函数之间有什么区别* 使用函数创建的生成器是早期ES6草案的一部分 //They have differrent prototypes console.log(a.prototype.constructor.constructor,b.prototype.constructor.constructor);//function Function() function GeneratorFunction() let a1=a(10); let b1=

使用function和function创建的生成器函数之间有什么区别*

使用函数创建的生成器是早期ES6草案的一部分

//They have differrent prototypes
console.log(a.prototype.constructor.constructor,b.prototype.constructor.constructor);//function Function() function GeneratorFunction()
let a1=a(10);
let b1=b(10);
//both create generators...
console.log(a1,b1);//Generator {  } Generator {  }
//but different generators: one returns value, another returns an object of special format
console.log(a1.next(),b1.next());//100 Object { value: 1000, done: false }
for(let a2 of a1)console.log(a2);
for(let b2 of b1)console.log(b2);
//They are equal when used in for ... of.

我见过这样的问题,但目前找不到…或者这个:
//They have differrent prototypes
console.log(a.prototype.constructor.constructor,b.prototype.constructor.constructor);//function Function() function GeneratorFunction()
let a1=a(10);
let b1=b(10);
//both create generators...
console.log(a1,b1);//Generator {  } Generator {  }
//but different generators: one returns value, another returns an object of special format
console.log(a1.next(),b1.next());//100 Object { value: 1000, done: false }
for(let a2 of a1)console.log(a2);
for(let b2 of b1)console.log(b2);
//They are equal when used in for ... of.