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

280
Views
What does it mean when a function is written like "name: function ()"?

I just have a super quick question about JavaScript so I'm not going to follow the general formatting of a question like usual.

I'm trying to understand some code in JavaScript, and the person who wrote it used a method that I'm not familiar with. As you see in the title, they've written it by typing the name of the function followed by a colon first, and then writing the actual function.

Example: myFunction: function () {}

Is anyone able to tell me what this means, why it's done, and what it accomplishes?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

It is part of Object Methods like:

const person = {
  myFunction: function() {}
};

you can invoke myfunction by using person.myFunction()

about 4 years ago · Santiago Trujillo Report

0

There are 3 ways of writing a function in JavaScript:

function myFunction() {} // Function Declaration
myFunction: function () {} // Function Expression
myFunction = () => {} // Arrow Function
about 4 years ago · Santiago Trujillo Report
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!