JavaScript Basics Points

Source: Internet
Author: User
Tags null null

JavaScript role:
1, the interactive effect of the page
2. Form Verification

JavaScript consists of:
1, ECMAscript---Core
2. DOM---Document Object model documents
3. BOM---Browser object model
window--window
history--history
location--Address bar (URL)
document--page (body) DOM

How does JavaScript work?
1. Get the Element (tag) obtained by ID, class, tag
2. Operation Contents
3. Operation Properties
4. Operation Style
5. Create a delete tag
6. Operation Events

JavaScript language (routines):
1. Comments, keywords, identifiers, constants
Single-line Comment
/*
Multi-line comments
*/
Identifier rules: Letters, numbers, underscores, $ symbols, etc. 4 components, numbers can not be used as a name
Constant: 10 1000 "Hello"
2. Variables, data types
variables:
Define and assign values: var variable name = value; name = value;
JavaScript Data type (6 types):
1, number (int (integer, no decimal)/float (decimal))
2, string "string" number of strings added stitching
3, Boolean Boolean type: Not true is false true (True) False (false)
4 NULL null value does not point to
5, undefined no definition
6. Object objects
(An array is part of an object)
3. Operators
1, arithmetic operator: +-*/% Remainder {+ +) self-increment-self-increment self-decrement before after + + + + + + + + + + + + + + + + + + +
Assignment operator: = + = =
2. Relational operators: > < >= <=! = = = value Size comparison (judging) = = = value size and data type comparison
3, logical operator:&&//or! Return: Back
4, ternary operator: expression
4. Control statements
Sequential structure
Branching selection Structure: if
else if
Switch: is a match for the specific value, no break is found in the next case, until the last case has penetration
Break: Jump out of

String to Character: parseint (content)


Loop structure: while () Dead Loop Do{}while () for ()
Two types of cycle usage scenarios:
For: The number of known loops
While: satisfies a conditional termination loop

Break: In the loop, switch inside has to use out of the current layer of the loop to terminate the loop
Continue: Use out of the loop inside the loop to enter the next cycle

for (var i=0; i<0;i++) {

}
for (1. initialization; 2. Condition judgment; 3. Change of State) {
4. Code of execution
}

while (1 expression 2. Code executed) {
}
1.
Judging whether an expression is ture

do{

}while (expression);
If expression 1 establishes execution code 1 otherwise executes code 2


if (expression 1) {
Code to execute
}else (expression 2) {
Code to execute
}
If set to execute if, do not establish execute else

switch (matching value) {

Case "value":

Code

Break

Default

Code

Break

}

Note: When no break is found, continue to find break


5. Arrays
6. Methods (Functions)
function Definition :
1.function Method Name (parameter list 1, parameter List 2 ... ){
Code Collection
}
2.var Method name = function (argument list) {}
function (method) does not execute without calling

Method Invocation: Method Name (parameter list 1, parameter List 2 ... )


Class, Object

Console.log (console print)

How to use javascript:
1. Write directly in the tag, the value of the event attribute (the common value is the method name)
<div onclick= "alert (123)" > Popup 123</div>
2. In the HTML file in the form of a label, the sign is script
<script type= "Text/javascript" >
JS Code
</script>
3. External references are displayed in the HTML file as a label, and the signature is script
<script type= "Text/javascript" src= "" ></script>

JS three kinds of pop-up windows:
alert ();---alarm window has no return value
Confirm ();---Select Window has return value Boolean type
Prompt ();---input window has a return value user input

JavaScript Basics Points

Related Article

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.