Web Front end java Script Learning 2017.7.6

Source: Internet
Author: User

Five output statements
1 alert (): Confirm modal frame
Alert (5);
Alert ("Heheda");
var num=10;
alert (num);
Alert ("This is a number, is" +num);
The variable must be detached from the string and connected with "+"
Alert is a program that can be blocked

PS: Each statement should be followed by a good point, indicating the end of a statement (there is a line break also means the end)

2 Console.log (): Print related information only in the console
Console.log (5);
Console.log ("Heheda");
var num=10;
Console.log (num);
Console.log ("This is a number, is" +num);

3 document.write (): Display relevant information in the document
document.write (5);
document.write ("Heheda");
var num=10;
document.write (num);
document.write ("This is a number, is" +num);

The difference between the three output statements:
Alert, console.log as output
Document.Write can parse the label string in the form of a label

Six input statements
var variable =prompt ("Please enter"): Input modal Box---input data is string type

string----> Numbers
parseint (variable), forcing a string to be converted to an integer
parsefloat (variable), forcing the string to be converted to decimals

Digital-----> Strings
String (variable) to convert a number to a string
"" + Variable: Changes the variable to a string type

Seven operators (operators)
Definition: is a set of special symbols used to manipulate data values
1 Arithmetic operators
+ - * / %
+: If the string is called a connector, if used in the number is the addition operation----splicing
%: modulo (take-up)---two numbers to divide the remainder
6%5=1*5+1
9%5=1*5+4
10%3=3*3+1
2%5=0*5+2

Multiplicative operator: */%
Additive operator: +-

21-tuple operator: an operator that can manipulate only one value
Front: Forward increment, forward decrement
Forward Increment (++i)
var i=10;
++i;//i=i+1;
Pre-decrement (-I.)
PS: First calculate itself, then return (Assignment) Participation value

Post: Post increment, post decrement
Post Increment (i++)
Post-decrement (i--)
PS: First assigns a value to the temporary variable, then computes itself, returns the value of the temporary variable
PS: The pre-set efficiency is high, so the front-facing

Unary Plus and minus operators
var num=2;
Num=+num;//+2
Num=-num;//-2

3 Relational operators: Values that are returned are Boolean types
> (Greater than) < (less than) <= (less than or equal) >= (greater than or equal)

4 equality operators: Values that are returned are Boolean types
Equality (= =) Inequality (! =): First converted after comparison
Congruent (= = =) Non-congruent (!==): direct comparison

5 Boolean operators
A logical non (!): First, the expression is converted to a Boolean value, and then the negation of it (in case of true false, False is true)
var res =!exp
Expression (exp):
Constant expression: 5 "Heheda" true ...
Compound expression: A statement composed of one or more operators and data values 8>5 9+4 ...
var res=!true;//false
!" Blue ";//false
!"";/ /true
!5;//false
!0;//true
! Nan;//true
!null;//true
PS: No matter what type of data is returned by the current expression, a Boolean value is returned after the negation
(!!):( When the truth is true, False is false)

B Logic and (&&)
var res = Exp1 && exp2;
(False is False, all true is true)
Exp1 true False False True
Exp2 false True True
Res false False True
PS: Returns more than just Boolean values, and logic is a short-circuiting operation: If the first value is false, the second value will return false regardless of what it is.

C Logic or (| |)
var res = EXP1 | | EXP2;
(The truth is true, all false is false)
Exp1 true False False True
Exp2 false True True
Res true false True True
PS: Returns more than just Boolean values, logic and is a short-circuiting operation: If the first value is true, returns true regardless of the second value.

6 Assignment operators
Simple assignment Operator: = assigns the right value to the left
Compound assignment operator: + = *=/=%=-=
var num=10;
num+=10;
Num=num+10

7 conditional operator (trinocular operator?:)
var res = bool_exp? Truevalue:falsevalue;
If Bool_exp is true, the TrueValue is returned to res, and if Bool_exp is False, Falsevalue is returned to Res.

8 comma operator
var num1,num2,num3,...;
var num1=1,num2=2,num3=3,...;
var nums= (,...); /can only take the last value

9 Priority order:
Unary operators (logical non) > Arithmetic operators > Relational operators > Logical OR (Logical AND) > Assignment operators
If you want to increase the precedence of an operator, add "()"

Web Front end java Script Learning 2017.7.6

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.