Hmmm, even outside the indexOf() question, this is a bit creepy to me. I hadn't previously tested, but these are all true, at least in Firefox 3.5 and IE8: "mpg" === "mpg" "mpg" !== new String("mpg") new String("mpg") !== new String("mpg") new String("mpg") != new String("mpg")
new Number(1) == 1 new Number(1) !== 1 new Number(1) != new Number(1) [] != [] new Array() != new Array() new Array() != [] new Object() != {} Is it an identity test -- is it the same actual object? -- maybe coupled with the way various types of data are stored internally? It looks like once the string "mpg" has been created, another literal "msg" is the same, but a new String object containing the same literal is not. The analogous tests with Number, Array, and Object values indicate somewhat different behavior, but since it's consistent across IE and Firefox, it seems inherent in the language. Can anyone explain, not *how* this actually works, but the logic behind it? Thanks, e On Sep 2, 4:28 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote: > You're probably running into equality vs. identity (loose equality vs. > strict equality). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---