Home  >  Article  >  Web Front-end  >  How to use init method in javascript

How to use init method in javascript

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-06-15 11:24:3310642browse

In JavaScript, the usage of the init method is "init:function (parameter) {js statement to be executed}". The init method is an initialization method, which initializes the entire page; if the init function is not called, the code in it will not be executed.

How to use init method in javascript

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

Recently when I was studying the MUI framework, I saw this code:

init: function(options) {
      var that = this;
      ……
  }

init, there is another layer outside this:

var _App = 
    init: function(options) {
        ……
        },
    ……
};
        ……

It is somewhat clear, it is just like in java An init method is defined in the object. The init method here is also an initialization method. Here, the entire page is initialized. Just call something like java:_App.init().

About the details: This is a json writing method. Use var o = {x: func, y for all functions, all variables, etc. : "", z: obj} this kind of architecture.

This class-like understanding means that var *** is regarded as creating an object, x: func defines a method, y: "" defines an attribute, and z: obj defines another object. Overall, it is similar to json writing {x: ***, y: ***}

[Recommended learning: javascript advanced tutorial]

The above is the detailed content of How to use init method in javascript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn