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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:58:21+00:00 2026-06-11T21:58:21+00:00

So im trying to make objects that have prototype inheritance without the new operator

  • 0

So im trying to make objects that have prototype inheritance without the “new” operator using closures.
My code is:

var TABLE=function (tableId) {
var table=(document.getElementById(tableId)||{}),
    colName=[],
    rows,
    cols,
    selectedRow;

//private methods

    var updateRows=function(){
        //Code that updates the number of row of the table
    }
    updateRows();

//Declare the public methods for the object

var methods={
    prototype:{
        cols:function () {
        return cols;
        },
        rows:function () {
            return rows;
        }
    }
};
    return methods;
}

var table=Table("Inventory")
alert(table.rows()) //I get undefined
alert(table.prototype.rows()) //I get the actual number of rows

What am i doing wrong? Do you think i could use some better way of coding for this

I appreciate all the help.

  • 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-11T21:58:22+00:00Added an answer on June 11, 2026 at 9:58 pm

    We have to use the new keyword in case you want to use prototypical inheritance.

    The best to use with example :-

    http://www.klauskomenda.com/code/javascript-inheritance-by-example/

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

Sidebar

Related Questions

I'm trying to make a genric code to serialize and deserialize any object that
I'm trying to make a list containing different objects. List<Object> list = new ArrayList<Object>();
I'm trying to build a prototype application that consists of a table of data
I'm trying to make a very simple game. In it I have objects (
i am trying to prototype the String Object to have a replaceWith Function that
I have a situation that I'm trying to make work with an array ,
Ok, so I'm trying to make a nice superclass for data-access objects that can
Im trying to make a method that creates a new object of a class,
I am trying to make asynchronous calls using xmlhttprequest object so it completely works
I'm trying to make a copy function and add it to the object's prototype.

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.