在这个页面中,我找到了一个新的JavaScript函数类型:
// NOTE: "function*" is not supported yet in Firefox.
// Remove the asterisk in order for this code to work in Firefox 13
function* fibonacci() { // !!! this is the interesting line !!!
let [prev, curr] = [0, 1];
for (;;) {
[prev, curr] = [curr, prev + curr];
yield curr;
}
}
Run Code Online (Sandbox Code Playgroud)
我已经知道了什么yield,let以及[?,?]=[?,?]做的,但不知道什么function*是注定的.它是什么?
function*() { .... }
Run Code Online (Sandbox Code Playgroud)
我刚刚在其他一些js代码中找到了这种形式的定义,这位明星的意思究竟是什么意思?谢谢