Python road, Day16-javascript Foundation
Development history: 1.table 2.table + CSS 3.div + CSS
Js:
JS Introduction:
1.JavaScript is designed to add interactive behavior to HTML Pages.
2.JavaScript is a scripting language (the scripting language is a lightweight programming language).
3.JavaScript is usually embedded directly into an HTML Page.
4.JavaScript is an explanatory language (that is, code execution is not precompiled)
Browser---interpreter:
1.html interpreter 2.CSS Interpreter 3.js Interpreter
How to write Js:
1.<!--js the first way of writing--<script> alert (' dsadsads '); </script>
The second way to write 2.js <script src= "a.js" ></script>
3. How to Annotate
3.1 Single-line comment//i am a single line comment
3.2 Multi-line comment/**/
4. Variable python:name = "alex" js:
4.1: local variable var name = "alex";
(1). variable is case sensitive (y and Y are two different variables)
(2). the first character must be a letter, an underscore (_), or a dollar sign ($)
(3). the remaining characters can be underscores, dollar signs, or any letter or numeric character comment: because JavaScript is case sensitive, variable names are also Case-sensitive.
4.2 Global variable name = "alex";
5. Data Type:
5.1 digits var num = ten; & nbsp; var num = 10.2; var num = 10.; var num =. 1; var num = "1234dsadsa"; parseint (num); 1234 parsefloat ();
5.2 string var str = "alex is sb"; Console.log (str); 5.3 List (array) var arrname = [element 0, element 1,....];
loop:
var arr = [' Zahngsan ', ' Lisi ', ' taoge ', ' Hailong '];
Python:
For I in Arr:print (i)
Js:
First Loop mode: var arr = [' Zahngsan ', ' Lisi ', ' taoge ', ' Hailong ']; for (var i=0; i<arr.length; i = i+1) { console.log (' DSADSADSA '); }
Second Way: var dict = {"name": "lisi", "age": ' 23 '}; for (var i in Arr) { Console.log (arr[i]); } 5.4 Dictionary (json) var Dict = {"name": "lisi", "age": ' 23 '};
5.6 BOOL True or FALSE
5.7 function
6. Basic Operators:
Arithmetic operators: + - * / % ++ -- + +: var num = 1; num++; num = num + 1;
Comparison operators: > >= < <= congruent and equal! = = = = = = = = =!==
Logical Operators: && | | !
Assignment Operator: = + = = *=/=
String Operator: + join, with one or two operands on either side is a string to do the join operation
7. Process Control:
1. Sequential structure Console.log ("meal"); Console.log ("sleeping"); Console.log ("hit the peas");
2. Branching structure
2.1 Single Branch structure if (expression) { & nbsp; }
2.2 Dual Branch if () { }eles{ }
2.3 multi-branch if () { }else if () { }else if () { }else{ }
2.4 switch...case swicth () {case:consoel.log (); Break }
3. Cycle structure first, once again.
Do...while
var n = 0;
do{
Console.log (' DSDSADSA ');
n = n + 1}
While (n<3);
4. Functions
Python:
def Test ():
Console.log ("fuck hailong");
There are three ways to write JS functions:
1.function Test () { Console.log (); }
2.var test = function () {console.log (' dsadsaj '); } Test ();
3. (function () {consoel.log (' DSADSA '); })()
8. Serialization
Json.stringify (obj) serialization of Json.parse (str) deserialization
2. Escaped characters in decodeURI () URL () non-escaped character decodeuricomponent () the non-escaped character in the URI component en The escape character in the Codeuri () URI encodeURIComponent () escapes the character in the URI component Urierror is thrown by the URL encoding and decoding method
DOM 1. Direct search: document.getElementById ("idname") document.getElementsByTagName ("tagname") document.getelementsbyname ("name") Document.getelementsbyclassname ("name") 2. Indirect search parentelement //parent node tag elements children //all sub-labels Firstelementchild //first child Tag element lastelementchild //last child Tag element Nextelementtsibling //next Brother Tag Elements Previouselementsibling //previous Sibling Tag Element
Python path, Day16-python base