Does the constructor of javascript need not be written in the entry function?

Does the constructor of

javascript need not be written in the entry function

used to be written in window.onload = function () {}, but today I suddenly found that I forgot to write the entry function at the beginning (the constructor is written in front of the html that needs to be operated), and the constructor can also be executed.
is this the case? no relevant

was found.
Mar.20,2021

there is no inevitable relationship between the two, unless you manipulate dom, in the constructor, then you may not get the dom element


what is the constructor of javascript?
should be your custom object (library package) and other initialization functions.
this is not necessarily related, as long as you initialize it before using it and deal with bindings that do not involve DOM.

Menu