+ 2

JS Main Method? (ProcessingJS)

Does javascript have a main method similar to Java main(string[] args) How do we interact live with our html website. Using setInterval for the method (although it can work as a loop) seems far fetched and absurd. What is the better way. KhanAcademy used something called ProcessingJS which updated on the fly. How does that not work here too?

17th Jun 2018, 4:08 AM
Andre Daniel
Andre Daniel - avatar
6 Respostas
+ 1
It run once when the page loaded. JavaScript would also run if there is event listening triggered or timer codes.
17th Jun 2018, 11:41 AM
Calviղ
Calviղ - avatar
+ 3
nope JavaScript has no main method,doesnt need one.. and i dont think processingJs is a standard part of js
17th Jun 2018, 4:16 AM
᠌᠌Code X
᠌᠌Code X - avatar
+ 1
If you need to run a function after a page loaded, it could be triggered by an event or set timer to run it. You could also create worker thread to run JavaScript, but it's not common on front end page.
17th Jun 2018, 12:13 PM
Calviղ
Calviղ - avatar
0
JavaScript does not need a startup function like Java, it runs directly inside <script></script> in a html file.
17th Jun 2018, 5:05 AM
Calviղ
Calviղ - avatar
0
Then how does it run infinitely, just like a main method would?
17th Jun 2018, 11:37 AM
Andre Daniel
Andre Daniel - avatar
0
So basically, if I want it to run more than once, I need to make an artificial run method and call it as a setInterval for something like every .01 seconds or so?
17th Jun 2018, 11:43 AM
Andre Daniel
Andre Daniel - avatar