Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
Structuring Javascript classes for interoperation

So like wading into a beach pool and finding it has a riptide, my journey in JS programming has gotten complicated quite quickly.

I have an application I am building that has a class, cataloque.js that loads and renders data. It currently does a few things that I would rather it didn't such as put up dialogs for the user.

It is imported into a file, core.js, that handles my user interaction and building parts of the UI

I want to take those user alert functions and put them into another class but then I run into some problems. A class can't be a module (as the this. operator is set to window. in modules) so I can't import another class into catalogue.js.

I also can't seem to reference functions in the core.js file from my class.

So what is the best way to structure this so I can import multiple classes and still have some way of having them 'talk' to the core.js functions?

To help illustrate:

core.js

  • imports catalogue.js creates new class variable
  • imports dialogs.js creates new class variable

So if I have code in the cataloque class that needs to alert the user and I want to call code in the dialog class how do I mediate that communication?

So catalogue calls core which then calls dialog to show the user a dialog

Do I need to declare a namespace in core.js? Is this just a crazy way to build something in JS?

Also, I have done a lot of searches for articles in this vein but I assume that since the class structure has undergone changes recently that there are not a lot of references available via searches so any good reading suggestions would be quite helpful.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!