for ex:
for (idx in my_array) {
do_stuff(my_array[idx]);
};
is not working anymore.
I took a screen-shot from my debugger:
http://bayimg.com/fAnhaAaBb
a screenshot without Orbited.js and stomp.js is below
http://bayimg.com/FaNhEAabb
for the first element of the array, instead of the value, i get some
weird text/function -indexof.
has anyone had this problem? how to fix this?
thanks a lot!
> for (idx in my_array) {
> do_stuff(my_array[idx]);
> };
>
> is not working anymore.
That's a very fragile operation in JavaScript, and writing code like
that is not recommended. Instead just iterate using:
for (var i = my_array.length - 1; i >= 0; i--){
my_array[i]
};
or something similar.
That said, Orbited probably shouldn't break it either. Neither of
your screenshots load for me, so I'm not sure what the problem was,
exactly. I assume either Orbited.js or stomp.js adds something to the
array prototype? Can you figure out where the addition happens, and
what it's there for?
Cheers,
Jacob
> That said, Orbited probably shouldn't break it either. Neither of
> your screenshots load for me, so I'm not sure what the problem was,
i have attached the two images. let me know if you still have problems
with them.
> exactly. I assume either Orbited.js or stomp.js adds something to the
> array prototype? Can you figure out where the addition happens, and
i am completely new to javascript and orbited. if you can give me some pointers
on how to do it, i can definitely try.
// Implement Array.indexOf (needed in IE 7 or lower).There you go.
// NB: This was borrowed from Mozilla.
// See http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:indexOf
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(elt /*, from*/) {
var len = this.length;
var from = Number(arguments[1]) || 0;
from = (from < 0) ? Math.ceil(from) : Math.floor(from);
if (from < 0)
from += len;
for (; from < len; from++) {
if (from in this && this[from] === elt)
return from;
}
return -1;
};
}