Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 838529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:19:10+00:00 2026-05-15T05:19:10+00:00

In my Javascript drag and drop build app, a variety of buildings can be

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:19:11+00:00Added an answer on May 15, 2026 at 5:19 am

    Just use a copy/clone method to restore the original state

    var defaults = {
        foo: "bar"
    };
    var building;
    
    function reset(){
        building = {};
        for (var key in defaults) {
            if (defaults.hasOwnProperty(key){
                building[key] = defaults[key];
            }
        }
    }
    

    Now you can just call reset() whenever you need to have building reset.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm implementing a drag & drop script in (plain) JavaScript. All good, except one
I'm using the native drag and drop API in javascript. How can I remove
I want to develop a javascript drag and drop application just like the one
I'm currently making a Drag-and-Drop javascript engine. I want to make one class (
I'm working on this drag and drop application with jquery/javascript, and I'm having to
Here is an interesting use of JavaScript: reordering items with drag and drop. The
I'm trying to detect the HTML5 Drag And Drop support in JavaScript. Modernizr seems
The following code will only let me drag and drop ONE clone onto a
I am doing a little app with JQuery, using drag-n-drop for the interface. Basically,
I have a JavaScript file with jQuery.pep (Drag and Drop jQuery plugin). I'm starting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.