Baidu Front-end learning diary 10--javascript Basic Grammar

Source: Internet
Author: User
Tags logical operators

1. Variable A. Variable type

Number numbers

String strings

Boolean Boolean True and False

Array arrays

Object objects

B. Variable declaration
var n;

Unlike other programming languages, in JavaScript you do not need to declare the type of a variable. JavaScript is a "dynamic type language", which means that unlike some other languages (translator Note: C, JAVA), you do not need to specify what data type (for example, number or string) the variable will contain.

2. Conditional statements and Loop statementsA. Conditional statements

If.....else

Else....if

Switch.....case break

Comparison operators

= = = and!==-Determine whether a value is strictly equal to, or not equal to, another.
< and >-determine whether a value is less than or greater than the other.
<= and >=-Determine whether a value is less than or equal to, or greater than or equal to another.

logical operators

&&-logic and; Makes it possible to tie two or more expressions, and the entire expression returns true only if each of these expressions returns TRUE.
|| -Logical OR; When any of the two or more expressions returns true, the entire expression returns TRUE.

! No

if (! ( Icecreamvanoutside | | Housestatus = = = ' On Fire ')

Ternary operators

A ternary or conditional operator is a small point of syntax that is used to test a condition and return a value/expression, if it is true, the other is false-in this case is useful, and can occupy fewer blocks of code than the If...else block. If you only have two options through true/false conditions.

(condition)? Run this Code:run this code INSTEADB.
B. Looping statements

For

While

Do.....while

Break jumps out of the loop

Continue skip to Next loop

3. Functions

Defining functions

function MyWay () {};

Calling functions

MyWay ();

return value

Return

function scope 

Global variables and local variables

Baidu Front-end learning diary 10--javascript Basic Grammar

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.