Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

88
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!