1.js Foundation

Source: Internet
Author: User

One or six data types:

    1. Number: Integer (octal first is 0, hexadecimal starts with 0x or 0X), floating-point numbers and Nan (non-number) values
    2. Boolean:js can only indicate its state with true and false, not 1 or 0, but when Boolean values are used in numeric expressions, true and false are automatically converted to 1 and 0
    3. String: The strings are quoted in single or double quotation marks, and the quotation marks appear in pairs. Backslash defines a number of characters that cannot be displayed
    4. Object: Includes array type arrays, date objects, and so on
    5. NULL: If NULL, indicates null or nonexistent
    6. Undefined: Indicates that the variable has been created but is not assigned a value

Escape characters in JavaScript
Escape Character meaning
\‘ Single quotation marks
\‘‘ Double quotes
\\ Back slash
\ r Enter
\ n Switch
\b Backspace
\ t Level-making character
\f Paper Feed

Second, operators and expressions

Seven Types of operators

    1. Arithmetic operators: + 、-、 *,/,%, + + 、--(add, subtract, multiply, divide, take surplus, sliding scale 1, decrement 1[7 species])
    2. Logical operators:&&, | |,! (Logical, logical, or logical counter [3])
    3. String operator: + (string connection)
    4. Comparison operators:<, <=, >, >=, = =, = =, =,!== (slightly [8])
    5. Conditional operator: Operand? result 1: Result 2 (conditional operator, unique three-mesh operator)
    6. Assignment operators: =, + =,-=, *=,/=,%=, &=, |=, ^=, <<=, >>=, >>>= (slightly [12])
    7. Bitwise operators: =, &, |, ^, <<, >>, >>> ([7])

Third, program control statements

    1. If condition statement: if (expression) {statement segment 1;} else{statement segment 2;}
    2. Switch statement: switch (expression) {case value1; statement Segment 1; Break;case value2; statement Segment 2; Break;...default; statement segment n;}
    3. For Loop statement: for (initialize loop variable; condition; increment) {Loop statement}
    4. While Loop statement: while (condition) {Loop statement}
    5. Do-while Loop statement: do{Loop statement}while (expression)

Note: The Do-while loop executes at least once the loop body; the break statement can jump out of the loop statement; The continue statement can skip the remaining statements within the loop into the next loop; label statements are used to add labels to statements

1.js Basic

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.