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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:58:15+00:00 2026-06-10T13:58:15+00:00

First of all, I’m quite new to both OOP and NodeJS. My only experience

  • 0

First of all, I’m quite new to both OOP and NodeJS.
My only experience with classes so far, are in PHP.

I’m trying to make a javascript class called Clients, using the defineClass module in NPM.
Then I want to add sub-classes to it, with even more functionality.
The reason I want some of the functionality in sub-classes, is because some of them might have quite alot of functionality.

Here is my code:

var defineClass = require("defineClass").defineClass

var Client = defineClass({
  scpConnected: false,

  constructor: function (socketId) {
    this.id = socketId;
  },

  test: function (test){
    console.log('Test!!! '+ test); 
  }
});

var SSH = defineClass({
  _super: Client,
  connected: false,
  busy: false,
  buffer: '',

  constructor: function () {
    queue = [];
  },

  ssh: {
    connect: function (IP) {
      console.log('Connecting to '+ IP +'...');
    }
  }
});

var client = new Client('Test');
client.ssh.connect();

It seems like “client” doesn’t get the SSH abilities as I was expecting.

What am I doing wrong here? 🙂

New Code

var defineClass = require("defineClass").defineClass

var Client = defineClass({
  scpConnected: false,

  constructor: function (socketId) {
    this.id = socketId;
  },

  test: function (test){
    console.log('Test!!! '+ test); 
  },

  SSH: defineClass({  
      connected: false,
      busy: false,
      buffer: '',

      constructor: function () {
        queue = [];
      },

      connect: function (IP) {
        console.log('Connecting to '+ IP +'...');
      }
    })
});

var client = new Client('Test');
client.SSH.connect('test');
  • 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-10T13:58:16+00:00Added an answer on June 10, 2026 at 1:58 pm

    As I can see in your sample, you are actually creating instance of Client instead of SSH:

     var client = new Client('Test');
     client.ssh.connect();
    

    You should write:

     var client = new SSH('Test');
     client.ssh.connect();
    

    Note that parent class doesn’t have the functionality of its children, it’s against the idea of inheritance.

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

Sidebar

Related Questions

First of all, I'm quite new to the Android and JAVA world (coming from
First of all, I want to make something clear before I get yelled at:
First of all i have to those categoryIDs 1-whos parentcategoryID only appears one 2-ParentCategoryID
First of all, some background: I'm trying to get in a list of integers
im new in php sql and stuff, and I've been trying to think in
First of all, I'm kinda new to the barcode formats and what I do
I am new to programming with OOP, I am trying to properly use the
first of all, I'm not good with jQuery and coding. I'm trying to achieve
first of all, I have to admit that I am new to Perl, so
First of all, this isn't for a keylogger, it's for an input in 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.