问题描述
我正在浏览MDN(Mozilla开发者网络)并遇到了
I was going through MDN (Mozilla Developer Network) and came across Iterators and generators
很自然地,我尝试了Google Chrome v21页面中提供的代码片段。具体来说,这段代码:
So naturally, I tried the snippets of code given in the page on Google Chrome v21. To be specific, this code:
var it = Iterator(lang);
for (var pair in it)
print(pair); // prints each [key, value] pair in turn
但是,控制台会返回以下错误消息:
However, the console returns this error message:
ReferenceError: Iterator is not defined
为什么? Iterator函数是否已被弃用?我错过了一点吗?感谢您的帮助和时间: - )
Why's that? Is the Iterator function deprecated or something? Am I missing a point? Thank you for your help and time :-)
推荐答案
来自:
V8旨在与JSC(WebKit / Safari中的ECMAScript实现)插件兼容。因此,它实现了许多ECMAScript的非标准扩展,这些扩展也在JSC中,其中大多数也是Mozilla的JavaScript语言。
V8 is intended to be plug-in compatible with JSC, the ECMAScript implementation in WebKit/Safari. As such it implements a number of non-standard extensions of ECMAScript that are also in JSC, and most of these are also in Mozilla's JavaScript languages.
没有计划添加不在JSC中的非标准功能到V8。
There is no plan to add non-standard features that are not in JSC to V8.
注意:JSC代表 - WebKit ECMAScript实现。
Note: JSC stands for JavaScript Core - the WebKit ECMAScript implementation.
这篇关于JavaScript迭代器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!