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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:40:57+00:00 2026-06-11T13:40:57+00:00

I have pretty big javascript class with bunch of methods stored in a single

  • 0

I have pretty big javascript class with bunch of methods stored in a single js file. This methods can be logically categorized like common methods, methods to filter data, navigation methods etc. Now I want this class being split by separate files each containing its own specific category methods and leaving all properties and common methods in the current file. Shortly speaking I need something that c# partial keyword is used for.

I would like to avoid using prototype as it means I have to type class name for every function like class.prototype.functionname = function () { ... } that does not look great.

UPDATE: This is how my class looks like

function MyClass() {
    var self = this;
    self.common = function() {...}
    self.filterData = function() {...}
    self.navigate = function() {...}
}

I do not know how to handle self properly with prototypes or extension

  • 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-11T13:40:58+00:00Added an answer on June 11, 2026 at 1:40 pm

    If your class does not use the prototype, you have little chance – it is one [too] big function. However, such big functions shouldn’t exist anyway, are you sure you need it to be a class (with multiple instances)? Then you should move the functions to the prototype as far as you can. If not, a singleton would make more sense for you, which is essentially nothing more than an object literal. You also might have a look at the [revealing] module pattern, which is what you need (or one of its flavors) – the (sub) modules usually can be spread easily across different files, potentially using a dependency tracking loader.

    If it does, you can easily split it up into the single parts. That does not mean you would need to repeat class.prototype.… = …, you can just use helper functions like extend

    MyFavLibrary.extend(class.prototype, {
        functionname: function functionname() {…},
        …
    });
    

    or a simple IEFE-closure:

    (function(proto) {
        // even some place for static, private helper functions
        proto.functionname = functionname() {…};
        …
    })(class.prototype);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty big JavaScript file here which I want to embed into
I have a pretty big view which is like 1000 x 1000. So I
I have been trying to serialize a pretty big object. This object uses dictionaries
I have a pretty big Javascript script with loads of global variables & functions
This is a big headache. I have a simple js file consisting of nothing
so I have a pretty big flash file on my homepage, which raises a
I have a pretty big problem with my TabHost. Although I have declared all
I have a very strange situation. I´m working on a pretty big Java application
I have an image on a webpage. It's a pretty big image, however. It's
I'm here to get some information. We have a product thats pretty big and

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.