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

179
Views
convert entire .js file into class declaration

I have a program I am making. Say it has a bunch of function declarations, class declarations, and a bunch of global variable declarations (all bad). Everything could be encapsulated into a class with subclasses, but doing so would be tedious. Is there a better way? Here's a simple example:

var global = "global variable";

var global2 = "global variable 2";

class Global {

   constructor(something){

   this.something = something;

   }

}

function global(something){

   return something;

}

How could I turn a file with code such as this, into one big class declaration? Should I do that, or is there a better solution? I'll rewrite it if I truly have to, but it'd be awfully tedious to do so.

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!