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

  • Home
  • SEARCH
  • 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 6729229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:15:52+00:00 2026-05-26T10:15:52+00:00

I am pretty much a novice in javascript programming and i would really need

  • 0

I am pretty much a novice in javascript programming and i would really need some help/advice.

What i am trying to do:
I have a function (or object?!) which looks like this:

var svgInteraction = function (containerId) {
    var svgNamespace = "http://www.w3.org/2000/svg",
        htmlns = "http://www.w3.org/1999/xhtml",
    mathns = "http://www.w3.org/1998/Math/MathML";

    svgInteractions = {};

    svgInteractions[containerId] = "I am " + containerId;
    console.log(svgInteractions);

    return function () {
        console.log(svgInteractions);
    }
};

i initialize a variable like this:

var svg1 = svgInteraction("container_1");
var svg2 = svgInteraction("container_2");

The problem is that, for each initialization of the svgInteraction, the svgInteractions objects reinitialize.

It outputs:

Object { container_1="I am container_1"}
Object { container_2="I am container_2"}

Is there any way to keep old values inside it?

Thank you

  • 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-26T10:15:52+00:00Added an answer on May 26, 2026 at 10:15 am

    Don’t set it to an empty object each time (svgInteractions = {}) the function is called.

    Try this…

    var svgInteraction = (function() {
    
       var svgInteractions = {};
    
       return function(containerId) {
         // Implementation
       }
    
    })();
    

    Here, svgInteractions is encapsulated but it will also be static for all calls to svgInteraction.

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

Sidebar

Related Questions

Pretty much what the title says really. We have some code that is .NET
I'm pretty much a novice to shell scripting. I'm trying to send the output
I'm pretty much a novice as far as WCF goes and I'm trying to
Pretty much I have a code like below that I'm trying to add </tr><tr>
I have a question that has pretty much been asked here: asp.net mvc Html.ActionLink()
please help! I'm really going nuts with this problem! I have a CGI perl
After much research I am still stumped. I have a serial port object which
Pretty much as the title. I have been asked if it is possible to
Pretty much what I am trying to do, is create the following image: So
I'm pretty novice as a JQuery user goes. I've got some experience implementing different

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.