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

196
Views
How to use of an instance of a class in another class

I have three separate library :

  1. Export.js : that written all export methods
  2. HamburgerMenu.js : Export.js used here
  3. Loding.js : display spiner to prepare export file

Created an instance of Export.js in HamburgerMenu.js then a method of instance passed through Loading.js to run method. But there is an error in Loding.js that can not access to editor in Export.js.

Export.js and Loading.js hasn't direct relation.

How can i solve it?

Export.js

class Export {

    constructor(editor) {
        this.editor = editor;
    }

     exportGeometry() {

        var object = this.editor.selected; // return error : editor is undefined
       ...
     }
}

HamburgerMenu.js

import { Export } from './Export';
import { Loading } from './loading';

function HamburgerMenu(editor) {
   var exportModule = new Export(editor);

   var loading = new Loading('Please Wait..', 'Preparing to download ...', 
        exportModule.exportGeometry);
   
}

Loading

class Loading {

    constructor(title, message, Fun) {

        this.title = title;
        this.message = message;

        Fun(); // Fun here is exportGeometry that passed from HamburgerMenu
    }

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!