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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:42:43+00:00 2026-06-08T14:42:43+00:00

I have a some JavaScript with a complex structure. Because I’m new comer to

  • 0

I have a some JavaScript with a complex structure. Because I’m new comer to JavaScript (only understanding some basic concepts) I don’t know how to use it properly.

I have two files : Circle.js and Line.js. In Circle.js, I want to use a class object defined in Line.js:

In file Circle.js :

Helper.using('py.Figures', function (ns) {

    ns.Circle = function (params) {
        // some additional methods and code here
    }
}

And in Line.js is :

Helper.using('py.Figures', function (ns) {

        ns.Line2Point = function (params) {
            // some addition methods and code here
        };
}

In Figures.Circle, in ns.Circle I want to use Line2Point but I don’t know how.
I think it should be :

line = new ns.Line2Point(params);

But It seem doesn’t work.

According to Helper Class, ns will point to helper.using, in this case py.Figures. Does it mean, ns is the same object/reference in both the files?

  • 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-08T14:42:46+00:00Added an answer on June 8, 2026 at 2:42 pm

    I don’t think this is doable in Javascript directly across files. If they are part of the same namespace you could share some ‘global’ objects to achieve this have the line2points and circles attach themselves to that global object:

    Ex:

    var myShapesNameSpace = {};
    

    Circle.js:

    (function(){
      var circle = {};
      circle.method1 = function(){...}
      circle.method2 = function(){...}
    
      myShapesNameSpace.Circles = circle;
    
    })(window.myShapesNameSpace = window.myShapesNameSpace || {}); //check if namespace object exists. Else create a new blank one.
    

    Line.js:

    (function(){
      var line= {};
      line.method1 = function(){...}
      line.method2 = function(){...}
    
      myShapesNameSpace.Lines= line;
    
    })(window.myShapesNameSpace = window.myShapesNameSpace || {});
    

    Now you can check for the existence of myShapesNameSpace.Circles or .Lines and call the corresponding methods accordingly.

    You can include files in javascript and reference objects across files unless they are exported in some global form either via window or your define global

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

Sidebar

Related Questions

I'm working on a new project which has some complex javascript. I can't post
In my web app, I have some complex objects written with JavaScript (ie nested
I have to do some complex work with a UIWebView and Javascript and always
I have a problem with my JavaScript code. I'm starting with some more complex
I'm a comer at JavaScript, and just learning some basic stuff (function, variable, etc)
I have some javascript where I append an option to a select: var myuniqueddl
I have some javascript code with do while outer loop and switch inner loop,
I have some javascript applying changes to some elements and a function loading more
I have some javascript that I am using for some audio on my website:
I have some Javascript attached to the Service Activity form which fires OnLoad. It

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.