I am iterating over an array in MooTools but seeing additional items when iterating through the array using the shorthand for..in loop. It works fine when I use the regular for loop. Is this a problem with MooTools polluting the global namespace or am I doing something wrong here?
There is a createTabs() function that iterates over an a...
UPDATE: The problem only occurs when I use an older version of jQuery (1.3.2) and not on the newest version (1.4.2).
ORIGINAL QUESTION:
I have found a weird behavior, and am wondering if there are any work-arounds. The javascript 'for' loop can be used to enumerate the property names of an object. I am finding though that on IE it d...
Hello,
I'm trying to write a Delphi program that will loop through each worksheet in an Excel file and format some cells. I'm receiving an error while trying to use the for-in loop over the Workbook.Worksheets collection, though. The error is specifically:
[DCC Error] Office.pas(36): E2431
for-in statement cannot operate on
coll...
I'm making a bookmarklet, but I've encountered some wierd behaviour in IE8. The code causing the problem is this:
var els = document.getElementById("my_id").getElementsByTagName("*");
for(var i in els)
{
alert(i+","+els[i])
}
The first thing that is alerted is "length, n". This isn't the case in chrome: just in IE8.
Interestingly...
In an article on yuiblog Douglas Crockford says that the for in statement will iterate over the methods of an object. Why does the following code not produce ["a", "b", "c", "d", "toString"]? Aren't .toString() and other methods members of my_obj?
Object.prototype.toString = function(){return 'abc'}
Object.prototype.d = 4;
my_obj = {...
I have this list:
names = ['john','Jonh','james','James','Jardel']
I want loop over the list and handle consecutive names with a case insensitive match in the same iteration. So in the first iteration I would do something with'john' and 'John' and I want the next iteration to start at 'james'.
I can't think of a way to do this using ...
I want to create a new object and assign some properties for each array stored within some json. I have this mostly working except...
for (var i in json) {
a = 0;
a++;
a = new Object();
for (var key in json[i]) {
var Key = key;
var Value = json[i][key];
...
I normally use this pattern to iterate over object properties:
for(var property in object) {
if(object.hasOwnProperty(property)) {
...
}
}
I don't like this excessive indentation and recently it was pointed out to me that I could get rid of it by doing this:
for(var property in object) {
if(!object.hasOwnProperty(prope...