Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

279
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda