Is 'next' a reserved Javascript identifier?
Is 'next' a reserved Javascript identifier? The following code of mine was silently failing (in FF 3) to create the object's key/value pair when the key was 'next'. However, when I switched my keys from prev/next to navPrev and navNext, the object gets constructed as I expected.
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;
开发者_JAVA技巧 }
navigationEventStubs.push(pageNavEvents);
}
Nope, check out this list of reserved JavaScript keywords:
http://www.quackit.com/javascript/javascript_reserved_words.cfm
Edit:
Actually, there would appear to be some use of the word as a function in JavaScript 1.7 gerator/iterators
https://developer.mozilla.org/en/New_in_JavaScript_1.7
Are you using Prototype or another Javascript framework? next
is part of Prototype's ultimate DOM traversal tookit:
http://www.prototypejs.org/api/element/next
精彩评论