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

  • SEARCH
  • Home
  • 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 322967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:59:15+00:00 2026-05-12T08:59:15+00:00

I know there are a lot of OO javascript questions on SO and I

  • 0

I know there are a lot of OO javascript questions on SO and I a have been reading a lot of resources…. BUT it is still far my most long winded learning curve so far!

I am not classically trained sorry, hence I will have to just show you guys in c# an example of what I want to acheive.

I hope you can help!

public class Engine
{
    public int EngineSize;

    public Engine()
    {
    }
}
public class Car
{
    public Engine engine;

    public Car()
    {
        engine = new Engine();
    }
}

guys I am not really worried about the private/public & naming conventions of the above C# example.

All I want to know is how to replicate this structure in Javascript?

Thanks!

  • 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-05-12T08:59:15+00:00Added an answer on May 12, 2026 at 8:59 am
    function Engine(size) {
        var privateVar;
    
        function privateMethod () {
          //...
        }
    
        this.publicMethod = function () {
           // with access to private variables and methods
        };
    
        this.engineSize = size; // public 'field'
    }
    
    function Car() { // generic car
        this.engine = new Engine();
    }
    
    function BMW1800 () {
      this.engine =  new Engine(1800);
    }
    
    BMW1800.prototype = new Car(); // inherit from Car
    
    
    var myCar = new BMW1800();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there are a lot of JavaScript escaping questions, but nothing seemed to
I know there a lot of similar questions to this, but I didn't find
I know there are a lot of similar questions on SF, but I think
I know there are a lot of questions around on this subject, but I've
I know there are a lot of such questions on stackoverflow but I couldn't
I know there are a lot of questions similar to mine, but I actually
I know there are a few questions out there but I've tried a lot
I know that there are a lot of similar questions, but no one the
A lot of questions have been asked and answered about running server-side javascript on
I know this topic has been discussed a lot , but I have a

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.