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

91
Vistas
Return an object of functions without specifying key-value pair in JavaScript

Could I please have an explanation on why returning an object of functions without specifying a key-value pair is valid? From my understanding of objects in JavaScript, objects must have key-value pairs, but the object being returned below does not.

function returnFunc() {
    return {
        printHello() {
            console.log('Hello');
        },
        printBye() {
            console.log('Bye');
        }
    }
}

returnFunc().printHello();

And if I try to return a literal without specifying a key-value pair, I get an error as expected.

function returnLiteral() { 
    return {
        'Hello',
        'Bye'
    }
} // THIS FUNCTION IS NOT VALID
about 4 years ago · Santiago Trujillo
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