Javascript Basics-Variables & operators

Source: Internet
Author: User

After looking for a work written by the baptism, feel oneself JS grammar grasp is not very system, today to comb down-variables and operators.

Basic article

and C language differences: is a weakly typed language, the declaration of variables do not need to specify the type, the name of variable names are also different; simple types are different ; types can be converted to each other

1. Naming

is a letter, the beginning of _,$, consisting of numbers, letters, underscores $, not including the key, the case-sensitive string called identifiers ( added the dollar sign, cannot start with a number ).

2. Affirms that

form: Var KeyName; It can be declared when it is initialized with multiple declarations.

Eg:var obj; var arr=[], objarr={};

Note: (1) No declaration type is required, the type is automatically converted according to the program's run. (2) If no definition is used, it will give an error; it is stated that the Undefinedd type is not assigned, and (3) The global variable is not declared with Var, which is analyzed in detail below the global variable.

3. Variable type

Simple Type: boolean string number undefined null

Note the point:

Boolean: The value of True,false is also converted to 0,1 use, isload () ==1;

String: When characters, or strings are string, can be either single or double quotation marks can be var str= ' adafsd ', str2= "abc", other with C language;

Number: denotes integers, decimals, integers include decimal, octal (078), hexadecimal (ox78), numeric constant: (Infinity means positive infinity large NaN means non-numeric)

NULL: is a null type with only one value NULL. indicates no data.

Complex Type: Array object

Array: A type that can be accessed with subscript, such as Var t=[a,b,c]; can be a complex array type: var t=[{a=b},{a2=b}]

Object type, which can represent the object's property-value, key-value pair. Any type can be nested. Access with. To access.

4. Transmit Value and address

When a variable is a simple type, it is passed value, if the variable is a complex variable, it is addressed, and the original object is passed a reference (either a pointer, or an alias, pointing to the memory space of the original object ).

Javascript Basics-Variables & operators

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.