The basics of JavaScript learning notes: javascript learning notes
Summary: Composition of javascript, role of each component,
I. Composition of javascript
Javascript
ECMAScript (CORE) DOM (Document Object Model) BOM (Browser Object Model)
1.1 ECMAScript
ECMAScript is a scripting language standardized through the ECMA-262, The ECMA-262 specifies the language: syntax, type, statement, keywords, reserved words, operators, objects
1.2 DOM
DOM maps the entire page into a multi-layer node structure. Each component of pages such as HTML and XML is a certain type of node, and these nodes contain different types of data.
1.3 BOM
Controls the parts outside the page displayed by the browser
Ii. <script> Elements
2.1 usage
External Reference javascript file:
Copy codeThe Code is as follows:
<Script type = "text/javascript" src = ".../../XX. js"> </script>
Page embedding javascript code
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Var first = "first variable ";
Alert (first );
</Script>
2.2 <script> attributes of an element
Defer delayed Script: the script will be delayed until the entire page is parsed before execution. Although it is delayed, the browser has downloaded the js file.
Copy codeThe Code is as follows:
<! DOCTYPE html>
<Html>
<Head>
<Script type = "text/javascript" defer = "defer" src = "demo. js"> </script>
</Head>
</Html>
In the preceding example, although the <script> label is in the
Defer only applies to externally introduced script files
Async asynchronous Script: you do not have to wait for the download and execution of the script on the page to asynchronously load other content on the page. Therefore, do not modify the dom during asynchronous loading.
Copy codeThe Code is as follows:
<! DOCTYPE html>
<Html>
<Head>
<Script type = "text/javascript" defer = "defer" src = "demo1.js">
<Script type = "text/javascript" defer = "defer" src = "demo2.js"> </script>
</Head>
</Html>
These are some basic javascript knowledge. I hope that you will not be able to read or fall asleep. Only by laying a solid foundation can you make a qualitative change.