2018-1-2javascript Basic Knowledge

Source: Internet
Author: User

Today, I started to learn about JavaScript.

A complete JavaScript consists of the core (ECMAScript), Document Object Model (DOM)/Browser object model (BOM) three parts.

JavaScript functions: 1. Page interaction effects; 2. Form validation

How to use javascript: 1. Get element (tag) ID class label signature

2. Operation Contents

3. Operation Properties

4. Operation Style

5. Create a delete tag

6. Operation Events

Page Popup content: 1.alert ();===> Display in window

2.document:write ();===> displayed in the upper-left corner

3.console.log ();===> Display in console

How to use javascript: 1. Write the value of the event property directly in the tag (the common value is the method name)

2. In the HTML file in the form of a label, the signature is script (there is no limit to the location) (script is a pair of tags, with the first tail)

3. External reference: In the HTML file as a label, the label signature is script.

JavaScript three types of Windows: Alert ();===> Alarm window, no return value

Confirm ();===> Select window with return value

Prompt ();===> input window, with return value

JavaScript basic syntax: 1. Comments, keywords, logos, etc.

2. variables, data types

3. Operators

4. Control statements

5. Arrays

6. Method (function) class, Object

Note: Single-line Comments (//) multiline Comments (/*/)

Identifier rules: Letters, numbers, underscores, $ symbols, etc. 4 parts, the number can not be a name.

Variables: Define and assign values. 1, var variable name = "VALUE;

2.var variable name;

Variable name = "Value";

Operator: 1, arithmetic operator. "+", "-", "*", "/"

2, assignment operator. "=", "+ =", "-=", "*=", "/="

3, comparison operator. (relational operators) ">", "<", ">=", "<=", "= =", "! ="

4, logical operator. ① and (&&); ② or (/); ③ Reverse (! );

5, ternary operator expression.

Self-increase self-reduction: n1++; n1--;

Self-increment reduction is not the same as in the post-op sequence

+ + in front, first + + after the calculation; + + after the first calculation after + +

Short-circuit Operation:&

JavaScript Loop statement: 1, If...else loop

if (expression) {

Code;}

else {

Code;}

2.switch statement:

N1=1;

Switch (N1) {

Case 1:console.log ("Today is Monday");

Break

Default

Console.log ("No matching value");

}

3. For loop:

for (① initialization; ② condition judgment; ③ State change) {④ code executed}

Example: for (Var i=0;i<3;i++) {Console.log (i)}

①②④③②④③②④③②

4. While loop:

while (① expression) {② code executed}

① Judging the expression result is not true

Example: Var n1=0;

while (n1<3) {console.log (n1);}n1++;

5. Do While loop

Code};while (expression) executed by do{;

2018-1-2javascript Basic Knowledge

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.