O is the index (or property) of array. You will access what's stored at that index by listo.
For(var o in list) o is the index (or property) of array. You will access what's stored at that index by listo. But for the arrays, it is better to use for loop as shown by Alnitak than for-in.
Update: For-in is to be used when you need to loop through all the properties. Since array is an object it has indices and properties. So for-in will iterate through all the indices and properties.
For-in is better for objects. E.g. Var obj = { p1: 1, p2: 2}; for(var prop in obj) { //... }.
Cream-corn: See update. This might give some hint on why not for-in for array: jsfiddle.net/BGurung/5tbdh. –?
Dec 23 '11 at 15:41 1 @cream-corn: for-in is used for enumeration. In JavaScript it is best not used on Arrays because you'll hit all enumerable properties, and people like to extend Arrays. So you use for-in when you want all enumerable properties.
You use for when you want iteration of indices. This was not the cause of your problem though. The problem was calling .draw() on a key, instead of using the key to get the value.
The answer you chose has misleading information. This answer is better. – am not I am Dec 23 '11 at 15:42 yes, I now realize this and the error of my ways.
Thanks all for a speedy reply :) – cream-corn Dec 23 '11 at 15:46.
For ... in ... gives you an object's keys and not its contents. So on an Array you will receive both the indices of the stored elements and the names of any other enumerable properties. Instead, you should use: for (var I = 0; I Length; ++i) { listi.draw(); }.
1 An Array is an object. The direct mistake was calling the method on the key (String) instead of the value. Though you're right that it is better to use a for statement.
– am not I am Dec 23 '11 at 15:32 1 @amnotiam text fixed - I was writing it in a hurry. – Alnitak Dec 23 '11 at 16:13 +1 for the update. – am not I am Dec 23 '11 at 16:44.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.