Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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 () {}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

It is part of Object Methods like:

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

you can invoke myfunction by using person.myFunction()

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading