main() function in JavaScript?

非 Y 不嫁゛ 提交于 2019-12-30 07:54:10

问题


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.


回答1:


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.




回答2:


"Main" function has nothing different then any other function (Its just a name). It will run when called and not automatically.




回答3:


It is just a name given to a function, there isn't such a thing as C "main" in javascript.



来源:https://stackoverflow.com/questions/8629859/main-function-in-javascript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!