Javascript basics, basics of photography for beginners
Javascript has three important components: ECMAScript, DOM, and BOM.
ECMAScript is the core language defined by ECMA specifications. In fact, this language does not contain input and output definitions. The ECMA Specification defines only the basis of this language, on which a more complete scripting language can be built. Our common Web browser is only one of the possible hosting environments implemented by ECMAScript.
DOM is both a Document Object Model (Document Object Model) and an application programming interface for XML but extended HTML. DOM maps the entire page into a multi-layer node structure. Each component of an HTML or XML page is a type of node that contains different types of data.
BOM is a Browser Object Model that provides a series of objects and APIs that can operate on browsers.
There are two ways to apply javascript code to a page.
Method 1: insert javascript code into the <script> tag of the html document.
Directly wrap javascript code using the script tag in the document. In some earlier browsers, you must add the type = "text/javascript" attribute to the script tag to correctly identify javascript code.
Method 2: store javascript code in an independent file and introduce the javascript file through the src attribute of the script tag.
Write the js Code into a separate js file. When necessary, introduce the js file through the script tag in the document.
1. Variables
Variables are defined by the var operator and the variable name.
Variable name naming rules: the first character must be a letter, underscore (_), or dollar sign ($); the variable name cannot contain spaces or punctuation marks (_) and $); variable names are case-sensitive. Reserved Words and keywords cannot be used. To make the variable name more readable, you can insert underscores to separate them.
2. Data Type
String)
The String type is used to represent a String that consists of zero or multiple 16-bit Unicode characters. The string can be composed of double
Quotation marks (") or single quotation marks (')
Number)
Number Type
Expressed in IEEE754 format
Integer and floating point value (the floating point value is also called a double-precision value in some languages ).