最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Is this.init = function() called every time file is loaded? - Stack Overflow

matteradmin7PV0评论

I can't find a definitive answer if an init function is called automatically when the file is loaded. Is this a built-in part of JS/Jquery, or am I missing where it's getting called from in some location of another file?

If it is being called automatically, is this reoccurring every time the file is loaded?

Example of the particular setup:

ExampleClass = function()
{
   this.init = function()
   {
          //...
   }
}

I can't find a definitive answer if an init function is called automatically when the file is loaded. Is this a built-in part of JS/Jquery, or am I missing where it's getting called from in some location of another file?

If it is being called automatically, is this reoccurring every time the file is loaded?

Example of the particular setup:

ExampleClass = function()
{
   this.init = function()
   {
          //...
   }
}
Share Improve this question asked Sep 23, 2011 at 14:34 BrizBriz 1751 gold badge2 silver badges12 bronze badges 1
  • 2 in your example there is no code ever being called, only defined. – zzzzBov Commented Sep 23, 2011 at 14:35
Add a ment  | 

3 Answers 3

Reset to default 4

no init is not called automatically when file is loaded.

Something else is calling it, that is not a behavior of javascript.

Init is called when DOM is ready, not called default or automatically when file is loaded.

Please see below link for more understanding.You will definitely like it.

Click me

Post a comment

comment list (0)

  1. No comments so far