JS Basic Knowledge Summary (All)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.