Js
First, JS overview
1.1 JS History
- 1992 Nombas developed the embedded scripting language for C-minus-minus (c--) (originally bundled in Cenvi software). Rename it scriptease. (The language that the client executes)
- Netscape (Netscape) received Nombas's philosophy, (Brendan Eich) developed a set of Netscape scripting languages in its Navigator livescript 2.0 product. Sun and Netscape are done together. And then the name is JavaScript.
- Microsoft then emulated a JavaScript clone called JScript in its IE3.0 product.
- To unify the three, the ECMA ( European Computer Manufacturing Association) defines the ECMA-262 specification. The International Organization for Standardization (ISO/IEC) also adopted ECMAScript as the standard (iso/iec-16262). From then on, the Web browser began to work (albeit with varying degrees of success and failure)
1.2 ECMAScript
Although ECMAScript is an important standard, it is not the only part of JavaScript, and certainly not the only one that is standardized. In fact, a complete JavaScript implementation is made up of the following 3 different parts:
- Core (ECMAScript)
- Document Object Model (DOM) Documents object models (consolidated js,css,html)
- Browser object models (BOM) Broswer object Model (integrated JS and browser)
- The vast majority of Javascript in development is object-based. It is also object-oriented.
To put it simply, ECMAScript describes the following:
-
- Grammar
- Type
- Statement
- Key words
- Reserved words
- Operator
- Object (encapsulates inherited polymorphism) based on the language of the object. Working with objects
Introduction Method of 1.3 JS
1 {#1 Direct Writing#}
2 <script>
3 alert(‘hello yuan‘) js block is recommended to be placed at the bottom of the body block
4 </script>
5 {#2 Import File#}
6 <script src="hello.js"></script>
Second, JS basic knowledge
2.1 Variables
Declare variables using the keyword ' var ', var a=1;
You can declare multiple variables on a single line.var name="lfd", age=20, job="lecturer";
You can declare variables without var. If you do not use Var then it is a global variable.
Variable name, the first character can only be letter, underscore, $ dollar symbol three select one, and case-sensitive, x and X are two variables.
Variable naming laws:
1 Camel notation
2 The first letter is lowercase, and the next letter begins with an uppercase character. E.g:
3 var myTestValue = 0, mySecondValue = "hi";
4 Pascal notation
The first letter is capitalized, and the next letter begins with an uppercase character. E.g:
6 Var MyTestValue = 0, MySecondValue = "hi";
7 Hungarian type marking method
8 Append a lowercase letter (or a lowercase sequence) to the variable named after the Pascal notation to indicate the type of the variable. For example, i for an integer and s for a string, as shown below
9 Var iMyTestValue = 0, sMySecondValue = "hi";
View Code
JavaScript of HTML