JS enforcement mechanisms unfinished notes

js synchronous and asynchronous synchronization
after the end of a task and then perform the following before a task, and task execution sequence alignment program is consistent
synchronization tasks are performed on the main thread, forming a thread of execution

Asynchronous
before a task is not over before the program can also perform other tasks
asynchronously js callback function is implemented by
asynchronous Generally there are three types
1, ordinary events, such as click, resixe etc.
2, resource loading, such as load, error, etc.
3, a timer, comprising setInterval, setTimeout other
asynchronous tasks associated callback function added to the job queue

js execution mechanism
1, the first synchronization task stack
2, asynchronous tasks (callback) placed in the task queue
3, once all of the simultaneous execution of tasks completed stack, in order, the system will read the task queue asynchronous task, then read asynchronous tasks waiting for the end state, into the execution stack, started

Since the main thread continue to get repeat tasks, perform tasks, and then get the task, then execute, so this mechanism is called event loop

The location object
window object provides us with a location attribute URL used to get or set form, and can be used to resolve the URL. Because of this property returns an object, so this property is also called location target
URL
Uniform Resource Locator, is the address of the standard resource on the Internet. Each file has a unique URL on the Internet, he pointed out that the file contains information about the position and how to deal with the browser
URL general syntax is
Protocol: // Host [: POST] [? Query] / path / #fragment
HTTP : name = //www.itcast.cn/index.html Andy Age = 18 is & # Link?
protocol: a communication protocol commonly used with HTTP, ftp, maito other
host: the host (domain)
default port number is omitted in the scheme: port No
path: the path is generally used to indicate a file or directory on the host address
query: parameters in the form of key-value pairs separated by an ampersand
fragment: fragment # back contents in common link


loaction common property! ! ! !
loaction.href get or set the entire URL! ! ! ! ! !
location.host returned to the host (domain)
location.port returns the port number if the port number is not an empty string
location.pathname return path
location.search return parameters
location.hash fragment # returns back to the common link content

Guess you like

Origin www.cnblogs.com/xf2764/p/12666643.html