Javascript
DOM Programming---> Manipulating HTML all tags (find HTML file and then manipulate)
JQuery----> Open source Modules (find, operate)
1. Import files
<script type= "Text/javascript" src= "J1.js" ></script>
<!--define a script tag to write JS code--->
<script type= "Text/javascript" >
Func ()
/*--referencing the function func in JS code */
</script>
2, JavaScript placement, generally placed in the HTML page of the body tag at the bottom, CSS can be placed inside the head tag, that is, the head of the HTML page
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<body>
<!--import js file src= "j1.js"---->
<script type= "Text/javascript" src= "J1.js" ></script>
<!--define a script tag to write JS code--->
<script type= "Text/javascript" >
Func ()
/*--referencing the function func in JS code */
</script>
</body>
3, comments, single-line comments with//, multiline comments with/*----*/
4. Declaration of variables
Local variable declaration starts with the keyword VAR
For example:
var name= "Eric"
global variable Declaration
For example:
Name= "Alex
5, declare the function passed in parameters, and then directly invoke the execution of their own
(function (ARG) {
Alert (ARG)
}) ("JavaScript")
"
6. Common methods and properties of strings
Obj.trim ()---> Remove spaces from a string
Obj.charat (Index)-------> by string so the subscript gets the corresponding letter
Obj.substring (start,end)-----> intercept a paragraph in a string, or slice
Obj.indexof (char)-------> Find the index value of a character in a string in the middle of a string
Obj.length----------> length of string
7. Arrays
declarations, such as:
var array = array () or var array = []
Add to
Obj.push (ele) append
Obj.unshift (ele) First insertion
Obj.splice (index,0, ' content ') specify index insertion
Removed from
Obj.pop () array trailing fetch
Obj.shift () array header fetch
Obj.splice (index,count) array specifies the position after count characters
Slice
Obj.slice (Start,end)
Merge
NewArray = Obj1.concat (OBJ2)
Flip
Obj.reverse ()
string of
Obj.join ('_')
Length
Obj.length
8. Circulation
var a = ' 123456789 ';
for (Var i=0;i<10;i++) {
Console.log (A[i]);
}<br>
For (var item in a) {
Console.log (A[item]);
}
9. Exception Handling
ty=
}catch (e) {
}finally{
}
This article from "Flat Light is true" blog, please be sure to keep this source http://ucode.blog.51cto.com/10837891/1844234
JavaScript Basics Learning