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 8690691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:57:19+00:00 2026-06-12T23:57:19+00:00

How do I add newObject to my array shapeArr ? Do I need to

  • 0

How do I add newObject to my array shapeArr?
Do I need to add a for loop?

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <style type="text/css">
            ul{ list-style-type:none;}
            div{ width:300px; height:200px; background-color:#0066cc; }
        </style>    
    </head>
    <body>
        <ul id="placeholder"></ul>
        <a href="#" id="btn">Add</a>

        <script type="text/javascript">

            function add(){

                function draw(){

                    var template = document.createElement("li");
                    template.innerHTML = "<div></div><a href='#' class='update'>Update</a>";                

                    document.getElementById("placeholder").appendChild(template);
                }

                var newObject = new draw();

                var shapeArr = [];

            }

            var btn = document.getElementById("btn");
            btn.addEventListener("click", add, false);

        </script>       
    </body>
</html>
  • 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-06-12T23:57:21+00:00Added an answer on June 12, 2026 at 11:57 pm

    You can use the push() method of the JavaScript Array to add new elements to the end:

    var newObject = new draw();
    var shapeArr  = [];
    
    // add the new Object
    shapeArr.push(newObject);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make JSON array using jQuery and got some problem: <html> <head>
I have the following Powershell code: Add-Type -Assembly System.Configuration [ExeConfigurationFileMap] $configMap = New-Object ExeConfigurationFileMap
I'm trying to expand and add a new object to a array inside a
I'm having a issue with the Array.splice() function. When I add an object to
Here I am trying to add object in array and checking if object is
I use a simple array: contentHouseOne[] that contains strings. But in the Do/While loop
I am parsing text output from a disk array that lists information about LUN
If I add a new object and go .save() then run a select, the
I add my url xxx/getjson.php to a webhook and once a person signup, it
The .add method appends components to the end of another component. I'm trying to

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.