'next'是保留的Javascript标识符吗?

时间:2011-05-27 14:17:58

标签: javascript reserved-words

'next'是一个保留的Javascript标识符吗?当密钥为“next”时,我的下面代码默默地失败(在FF 3中)来创建对象的键/值对。但是,当我从prev / next navPrev和navNext切换键时,对象按照我的预期构造。

        var unimplementedNavEvent = function() {console.log('Un-implemented Page Navigation Event')};
        var navigationEventStubs = [];

        for (var i=0, n=pages.length; i<n; i++) {
            var pageNavEvents = {href: pages[i], navEvents: {}};
            if (i !== 0) {
                pageNavEvents.navEvents.prev = unimplementedNavEvent;
            }
            if (i < n-1) {
                pageNavEvents.navEvents.next = unimplementedNavEvent;
            }
            navigationEventStubs.push(pageNavEvents);
        }

2 个答案:

答案 0 :(得分:1)

不,请查看保留的JavaScript关键字列表:

http://www.quackit.com/javascript/javascript_reserved_words.cfm

修改

实际上,在JavaScript 1.7 gerator / iterators中似乎有一些单词用作函数

https://developer.mozilla.org/en/New_in_JavaScript_1.7

答案 1 :(得分:0)

您使用的是Prototype还是其他Javascript框架? next是Prototype最终DOM遍历的一部分:

http://www.prototypejs.org/api/element/next