Version 1.js HelloWorld
<script type= "Text/javascript" >
Alert ("HelloWorld");
</script>
2. Notes
Single-line//
Multi-line/**/
3. Operators
+ 、-、 *,/,%, + =,-=, = = (same value), = = = (same type and value)
4. Logical operators
| |, &&
5. Defining variables (weakly typed)
var num= 1;
var string = "I am Chinese";
var Myboolean = true;
6. Method (defined by function)
<script type= "Text/javascript" >
function Fun (A, b) {
alert (A+B);
}
Fun ("Iam", "Chinese");
</script>
7. Process Control Statements
if () {}else{}
while () {}
Do{}while ()
Switch () {case 1:break;case 2:break;default:3;}
Continue end Current loop, enter Next loop
Break Exit Loop
8.js objects
var obj = new Object ();
Obj.name = "Tom";
Obj.age = 18;
function Fun (A, b) {
Return a + ":" +B;
}
Obj.myfun = fun;
Alert (Obj.myfun (obj.name,obj.age));
9.undefine, NULL
Undefine defined variable has no value assigned to it as Undefine
var A;
alert (a);//result is undefine
Null to place the variable null
var b=1;
b = null;
alert (b);//result is null
10. Common methods
Manipulating the String class
Manipulating the Date class
JS Basic Knowledge Summary (All)