reinitializing javascript object's properties

Posted by Pino on Stack Overflow See other posts from Stack Overflow or by Pino
Published on 2010-06-06T17:17:13Z Indexed on 2010/06/06 17:22 UTC
Read the original article Hit count: 302

Filed under:
|
|

In my Javascript drag and drop build app, a variety of buildings can be built. The specific characteristics of these are all saved in one object, like

var buildings = {
house: ['#07DA21',12,12,0,20],
bank: ['#E7DFF2',16,16,0,3],
stadium: ['#000000',12,12,0,1],
townhall: ['#2082A8',20,8,0,1],
etcetera
}

So every building has a number of characteristics, like color, size, look which can be called as buildings[townhall][0] (referring to the color). The object changes as the user changes things. When clicking 'reset' however, the whole object should be reset to its initial settings again to start over, but I have no idea how to do that. For normal objects it is something like.

function building() {}
var building = new building();
delete building;
var building2 = new building();

You can easily delete and remake it, so the properties are reset. But my object is automatically initialized. Is there a way to turn my object into something that can be deleted and newly created, without making it very complicating, or a better way to store this information?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about object