Beware of properties inherited from the prototype of the object (this can happen if you include any libraries on your page, for example, older versions of Prototype). You can verify this using the hasOwnProperty() object method. This is usually a good idea when using for...in loops:
var user = {}; function setUsers(data) { for (var k in data) { if (data.hasOwnProperty(k)) { user[k] = data[k]; } } }
Tim Down Jun 02 '10 at 15:07 2010-06-02 15:07
source share