Public properties for Objects in Javascript


/ Published in: JavaScript
Save to your folder(s)

This function allows an object's property names to be read by using an index. The properties can be accessed like: someobject.propertyNames[0] or someobject.propertyValues[0]. But you first have to make the object's properties available by calling someobject.makePublic(['name1','name2','name3',...,'nameN']). The array in the makePublic function is an array of the names of the properties you'd like to make available. Perhaps you're only interested in ['foo','bar']. This is useful for situations where you don't explicitly know if an object carries all properties, but you have an array of all the possible properties available.

URL: http://rolandog.com/archives/2006/07/18/konstructor

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.