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?
>Solution :
It is part of Object Methods like:
const person = {
myFunction: function() {}
};
you can invoke myfunction by using person.myFunction()