(5) JavaScript Study Notes-Variables

Source: Internet
Author: User
I. Variable type 1. JS is non-type, that is, JS variables can store any type of value; 2. so when necessary, JS can quickly and automatically convert one type of value to another type; 2. Variable Declaration [javascript] // declare a single variable vara; // declare multiple variables... syntaxHighlighter. all ();

I. Variable type

1. JS is non-type, that is, JS variables can store any type of value;

2. When necessary, JS can quickly and automatically convert one type of value to another type;

2. Variable Declaration

[Javascript]
// Declare a single variable
Var;
 
// Declare multiple variables
Var a, B, sum;
 
// Declare and initialize binding
Var msg = "hello ";
Var I = 0, j = 0, k = 0;
 
// Var can also be part of the for Loop
For (var I = 0; I ++; I <10) document. write (I ,"
");

It is legal to declare the same variable multiple times, except that the value is re-assigned.

Iii. Scope of Variables

1. Local variables defined in the function have a higher priority than global variables;

2. Although var can be used in the global scope, you must use var to declare local variables.

4. undefined variables and unassigned variables www.2cto.com

1. assign values to undeclared variables without causing errors. The program will be declared implicitly in the global scope;

2. the unassigned variable has been declared. The read value is undefined.


By: dxh_0829

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.