Rhino 中没有 Array.filter() 吗?
为什么我不能在 Rhino 中使用Array.filter()
?
代码是这样的:
var simple_reason = ["a", "b", "c"];
print(typeof simple_reason.filter);
var not_so_simple_reason = new Array("a", "b", "c");
print(typeof not_so_simple_reason.filter);
两种情况都输出“undefined”。
Why can't I use Array.filter()
in Rhino?
The code is like this:
var simple_reason = ["a", "b", "c"];
print(typeof simple_reason.filter);
var not_so_simple_reason = new Array("a", "b", "c");
print(typeof not_so_simple_reason.filter);
Both cases output "undefined".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Javascript 数组没有标准化的(ES5 规范在此后一个月发布)答案已发布。) MDC 参考页面 为您提供了一个兼容性示例,用于那些不支持它的实现...filter
函数,它只是标准的扩展。There is no standardized(There is as of the ES5 spec published just a month after this answer was posted.) The MDC reference page gives you an compatibility sample to use for those implementations that do not support it...filter
function for Javascript Arrays, it is only an extension to the standard.您正在使用不实现 JavaScript 1.6 的过时版本的 Rhino。尝试Rhino 1.7。
You are using an outdated version of Rhino that does not implement JavaScript 1.6. Try Rhino 1.7.
过滤器是标准的javascript吗?自 1.8 起,它仅在 Mozilla 中出现(或者 此参考 告诉我)
Is filter standard javascript? It is only in Mozilla since 1.8 (or so this reference tells me)