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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:33:17+00:00 2026-06-08T23:33:17+00:00

I’m a comer at JavaScript, and just learning some basic stuff (function, variable, etc)

  • 0

I’m a comer at JavaScript, and just learning some basic stuff (function, variable, etc) and I don’t know so much about complex structure in JavaScript.

When I read the source code of one of the web applications, there is a big point that I cannot understand. Here’s the code :

Helper.using('py.Figures' , function (ns) {
    ns.Point = function (params) {
        ns.Figure.call(this, params);
        this.setType('Point');

        this.visual(new Kinetic.Circle({
            radius:5, strokeWidth:2,
            fill:'red', stroke:'black',
            draggable:false
        }));

        this.getX = function () {
        };
        this.getY = function () {
        };
        this.getPosition = function () {
            return {
                x:this.getX(), y:this.getY()
            }
        }

        ns.Point.distance = function (p1, p2) { // some code }

        ns.MidPoint = function (params)  { // some code }       
};

1) First point that I don’t know in above code is the first line declaration :

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

Many files in this document use this structure. In this document, there is a file name Helper, but when I search in this document, I don’t see some thing like py.Figures (by using Control + F). So, what does it really points to?

Above line looks something like a function, so what does function(ns) mean in this, it looks like parameter, but I don’t think so.

2) The second point I don’t know is :

ns.Point, ns.Point.distance, ns.MidPoint look like methoda. So, function(ns) is a class, right ? And if ns.Point is a method, why in this method, there are other methods like getX and getY and it makes me feel that those look like a class too.

Sorry if my question is silly, but this code looks strange to me, and I don’t see anything familar with some language I have learnt (Java, C#), or another scripting language too (Python)

Thanks.

  • 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-08T23:33:19+00:00Added an answer on June 8, 2026 at 11:33 pm

    1) That function (ns) {... } is indeed an argument. The function is parsed, and the pointer to the function is passed to the function Helper.using. You won’t see these thing in Java, but I think it’s one of the awesome points of Javascript.

    It’s the usual way to define callbacks, and that argument function looks like a callback indeed.

    2) No, ns is a class object, or better, is generically an Object. It doesn’t need to be an instance of a class. Then the callback function defines the method Point on the object ns. In the body of the method, it defines (or maybe redefines) the methods getX, getY and getPosition, because this refers to the object ns.

    On a second look, ns.Point is indeed a function, but it may serve as a class definition, so in other parts of the code you may notice something like new ns.Point(...). That’s how “classes” work in Javascript.

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

Sidebar

Related Questions

I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.