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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:57:03+00:00 2026-06-05T15:57:03+00:00

I have a javascript object, which I’ve added a number of prototyped functions to,

  • 0

I have a javascript object, which I’ve added a number of prototyped functions to, which mostly depend in some way on the members of the object.

myForm() {
    this.property1 = "Prop1";
    this.property2 = "Prop2";
}

myForm.prototype.loadValues = function(){ /*...*/);

myForm.prototype.setValues = function(){ /*...*/);

myForm.prototype.doStuff = function(){ /*...*/);

There are enough functions/code that it is currently sitting at ~4 thousand lines, and it is driving me nuts every time I have to debug it using dev tools/firebug. I was thinking of splitting this up as such.

myForm.js –

myForm(){
    this.property1 = "Prop1";
    this.property2 = "Prop2";
    new myFormLoadActions();
    new myFormSetActions();
    new myFormDoStuffActions();
}

myFormLoadActions.js

myFormLoadActions(){
    myForm.prototype.loadValues = function(){ /*...*/);
}

myFormSetActions.js

myFormSetActions(){
    myForm.prototype.setValues = function(){ /*...*/);
}

myFormDoStuffActions.js

myFormDoStuffActions(){
    myForm.prototype.doStuff = function(){ /*...*/);
}

I’ve trialled this, and it seems to work functionally. Is this a reccomended way of dealing with a large number of prototyped functions, or is there a better way?

  • 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-05T15:57:04+00:00Added an answer on June 5, 2026 at 3:57 pm

    Keep your old code, but simply scatter assignments to prototype over multiple files:

    File 0

    myForm() {
        this.property1 = "Prop1";
        this.property2 = "Prop2";
    }
    

    File 1

    myForm.prototype.loadValues = function(){ /*...*/);
    

    File 2

    myForm.prototype.setValues = function(){ /*...*/);
    

    As I noted in the comments, this is just a problem of one class doing too much but you realize that and just want smaller files, so here you go 🙂

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

Sidebar

Related Questions

I have a javascript object which has some defined variables and attaches some event
I have some data which I originally stored in a generic Javascript object, with
I have to maintain a JavaScript object with some 30-40 properties, which I update
I have javascript object which consists of complex array of structures with nested structures
I have an javascript object with Date property which is being converted to JSON
I have a few JavaScript functions that behave as event listeners for an <object/>
I have javascript date object which gives me a date string in this format,
It's a simple question i have, I have a javascript object which is declared
I have a nested javascript object called data. Is there any way to iterate
I have a third party flash object which i can manipulate through a javascript

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.