Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

277
Views
how do I create a group for objects in ES5 javascript

I have created objects and prototypes in ES5, now I want to create a new prototype which will group existing object, I have this code

    const person = function(firstName,lastName){
    this.firstName =firstName;
    this.LastName = lastName;
    
    this.getFullName = function () {
    return firstName + ' ' + lastName ;
    };

    this.setFullName = function(firstName, lastName) {
    firstName = firstName.split(' ')[0];
    lastName = lastName.split(' ')[1];

    };    
    
    };

I created a student prototype that is an extension of the person class

    const student = function(firstName,lastName, grade ) { 
     person.call(this, firstName, lastName);
    
    this.Averagegrade = grade;
     };


  const group = function(Title, firstName,lastName, grade ) { 
       this.Title = Title;
       person.call(this, firstName, lastName);
       student.call(this, grade);
    
    
    
       const addstudent = Object.create(person);
           return firstName + ' ' + lastName ;
         
    
    
    }; 


group.__proto__ = student;
const john = new student('Jack','Sparrow', '53');
john.setFullName('Jack', 'Sparrow');

   const group1 = new group( "group1");
   group1.addstudent(john);
    console.log(group1);

but I keep getting this as output

     group {
      Title: 'group1',
      firstName: undefined,
      LastName: undefined,
      getFullName: [Function (anonymous)],
      setFullName: [Function (anonymous)],
      Averagegrade: undefined
    }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!