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

How to use init method in javascript

醉折花枝作酒筹
Release: 2021-06-15 11:25:10
Original
10809 people have browsed it

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;
      ……
  }
Copy after login

init, there is another layer outside this:

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

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!

Related labels:
js
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template