main() function in JavaScript?

Isuru picture Isuru · Dec 25, 2011 · Viewed 27.5k times · Source

I have seen a main() function in some JavaScript files I have come across. Is it the same main function as you use in other languages such as C#, C++?? If you put a main function in your JS file, is that where the code starts executing? Or is it just another name used for a function?

I have searched the web but didn't find anything useful regarding this matter.

Answer

FishBasketGordo picture FishBasketGordo · Dec 25, 2011

No, main is not the same in JavaScript as in C languages. It's just another function, but the original programmer is probably using the name as a convention to indicate where the code should start running.