On Wednesday, October 10, 2012, Lee Goddard wrote: > Thanks, Olivier, > > I understand, though I'm not happy about what's going on! > > Lee
this is because elements is on the prototype. you have 2 patterns here. one. Object.keys(Object.clone(this.elements)) two. don't add this to the proto but instance. eg addElements: function(){ this.elements = {} }, initialize: function(){ this.addElements(); Object.keys(this.elements); } something like that > > On 10/10/2012 16:44, Oliv wrote: > >> Hi, >> > > > > In the Object.keys function, it is using the hasOwnProperty function > > as a test before returning keys, and it will return false if the key > > comes from an inherited (ie prototype) property. > > > > During the mootools Class object creation, the object passed in > > parameter is merged in the prototype of the object Class, so you > > can't get the keys with Object.keys(). > > > > > > I hope to be understandable, cheers, Olivier Gasc > > > > Le mercredi 10 octobre 2012 14:50:55 UTC+2, Lee a écrit : > > > > I'm sure I'm doing something daft, but why doesn't > > Object.keys(this.obj) work? > > > > http://jsfiddle.net/leegee/**cvrvK/4/<http://jsfiddle.net/leegee/cvrvK/4/> > > <http://jsfiddle.net/leegee/**cvrvK/4/<http://jsfiddle.net/leegee/cvrvK/4/> > > > > > > Thanks... > > > > Lee > > > > > -- Dimitar Christoff "JavaScript is to JAVA what hamster is to ham" @D_mitar - https://github.com/DimitarChristoff