JavaScript Basics-variable-operator-flow control statements

Source: Internet
Author: User
Tags switch case

JavaScript composition

A complete JavaScript implementation is made up of the following 3 different parts:

ECMAScript: Describes the grammar and basic objects of the language;

The Document Object model, or DOM, is a description of the methods and interfaces for handling Web page content;

Browser object models (Browser object model, BOM): Describes the methods and interfaces that interact with the browser.

Variable

Variable type: Object String function Boolean undefined null number

JavaScript is a weak type, declaring a variable cannot declare a data type: int i=0;

can only be i=0 by VAR; declaring variables, unlike var in C #, is not a type inference in C #

JS is a dynamic type, so var i=0;i= "ABC"; it's legal.

Determining variable Initialization

The true and False in JS

True: true, not 0 digits, non-empty string, non-empty object

False: False, number 0, empty string, empty object, undefined

var a=false or a=0 or a=null or a=undefined or a= '

if (a) false

Operator

Programming languages are basically the same, listing Special:

1. = = =,! ===

A==b first converts the type, then compares, A===b does not convert the type, directly than

var a = 1;

var B = "1";

Alert (A = = B); True

Alert (A = = B); False

2 | | Returns the first value that is not false (the object can also), or the last value if all is false, the returned result is not necessarily a Boolean value

var a=2;

var b=0;

var c=b| | A

Window.alert (c); Output 2

Process Control Statements

Determine if else, switch case

Loop while (does while) for

JS does not have a foreach but can be used like a foreach

for (var item in data)

{

alert (item);

}

Jump out of break, continue


JavaScript Basics-variable-operator-flow control statements

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.