standard library

The use of this in objects

The this keyword is a very important syntax point. If you can't understand this in javascript programming, most programming tasks cannot be completed.

This returns an object, in short, the object where the property or method is currently located.

The use of this in functions

The pointing of this cannot be determined when the function is defined. Only when the function is executed can we determine who this points to. In fact, this ultimately points to the object that calls it.

Web Storage

LocalStorage: Permanently stored in the browser, but it should be noted that data cannot be shared between different browsers.
SessionStorage: The basic storage of the current page session, when the browser is closed or the page is closed, the data will be lost.

GlobalStorage: replaced by localStorage in HTML5.

Error objects and try..catch statements

An example of an Error object must have a message property, which indicates the prompt message when an error occurs. For most Javascript engines, the Error object also provides name and stock properties, which represent the name of the error and the stack information of the error respectively. They are non-standard and not every Error instance needs to be implemented.

In order to handle errors, we need to use the try...catch structure. It is allowed to define a finally block at the end of a try...catch block, indicating a statement that must be run later regardless of whether an error occurs. In the finally block is generally to do some cleanup work.


Window object

All browsers support the window object. It represents a browser window.
All JavaScript global objects, functions, and variables are automatically members of the window object.
Global variables are properties of the window object.

Global functions are methods of the window object.

JavaScript timing events

The clearInterval() method is used to stop the function code executed by the setInterval() method.


The setTimeout() method returns a value. In the above statement, the value is stored in a variable named t. If you wish to cancel the setTimeout(), you can use this variable name to specify it.




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325483520&siteId=291194637