开发者

Why does my "next" property disappear in my JavaScript hash in Firefox 3.6

I'm creating a hash as an options object to pass to a jQuery plugin. One of the keys I need to use, as defined by the plugin, is next.

This works fine in Safari (so I assume Webkit in general) but in Firefox its removed, or ignored or something... its just not there. For example:

var opts = {
  "next": "some selector string",
  "prev": "some other selector string",
  "anotherOption": 1
};

console.log(opts);

Ouput:

anotherOption      1
prev               "some othe开发者_如何学运维r selector string"

It's driving me crazy. What's more, there are tons of plugins and things that use this key name in some sort of options hash and I have never noticed this behavior before. Can anyone tell me what is going on here and how to work around it? (I've tried doing opts.next = "something" instead but it yields the same result).

It also not an issue with the surrounding code - I've typed the example (minus the console.log call) into my Firebug console and gotten the same result.


It's a bug in Firefox.

The bug does prevent Firebug from printing it, but the actual Object should still have the next property correctly defined.


The next property does not print out in Firebug console, but it is indeed defined. This may be a problem with Firebug, not JS. Your code should still work.

>>> var v = {};
undefined
>>> v.next = 'foo';
"foo"
>>> v.prev = 'bar';
"bar"
>>> v
Object { prev="bar"}
>>> v.next
"foo"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜