Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

278
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda