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

113
Vistas
Add unlimited values into objects from textbox in JavaScript

Can you please show me a simple code which add unlimited values into JavaScript objects. I don't want single view "Toyota, 2014". I want show lists value after I add value from textbox.

 class Car {
      constructor(name, year) {
        this.name = name;
        this.year = year;
      }
    }

At code below, this is single value to add, but I need add many value doesn't matter, how many of number I want to add.

const myCar = new Car("Toyota", 2014); 

I expect to view many different values like

Toyota, 2014
Opel, 2018
Volkswagen, 2021
and many mores
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It sounds like you want an array of Car objects:

const cars = [];

Then adding a Car is:

cars.push(new Car(make, year));
// Or some people do, which also works:
cars[cars.length] = new Car(make, year);

...where make and year come from the text boxes.

When you want to list them all, you'll use some kind of loop (the exact kinds depends on how you're listing them). My answer here shows the various ways you can loop through arrays.

More about arrays on MDN.

about 4 years ago · Juan Pablo Isaza Denunciar
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