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

225
Vistas
difference between constructor and class in javascript

what is the const halley=... referring to?Is it storing the new created object?or is itself a new object?and what does the Dog after the new keyword means?Class or constructor?

class Dog {
 constructor(name) {
   this.name = name;
   this.behavior = 0;
 } 
}

const halley = new Dog('Halley'); // Create new Dog instance
console.log(halley.name);
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

In JavaScript, a constructor function is a function designed for use with the new keyword to create instances of a type of object. Typically you would assign something to its prototype property to define properties that would be inherited by the instance.

The class keyword is a newish feature that allows the creation of a constructor function and its associated prototype using syntax which looks more like traditional OO syntax in other programming languages.

The value assigned to Dog is both a class and a constructor function.

about 4 years ago · Juan Pablo Isaza Denunciar

0

This part define the class. A class is like a recipe to make objects. A constructor is a method of a class that define how to create new instances (objects):

class Dog {
 constructor(name) {
   this.name = name;
   this.behavior = 0;
 } 
}

This part create an instance (object) of the class Dog:

const halley = new Dog('Halley');
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