JavaScript Getting Started: variables in 003-JS

Source: Internet
Author: User

The programming languages are the same. JS also contains variables.
First, JS variables are case sensitive. Note that number and Number are different variables. Whether it is a common type or an Object type, for example, Object obj and Object Obj are two objects.
Then assign values to variables, which are basically the same. You can declare the values before assigning values,

Var I; I = 0;
You can also assign values when declaring them,
Var I = 2;
If you do not assign a value to a variable, it will not change, for example
Var I = 2; var I;
Because I is not re-assigned, I is still 2.
The object variables are interesting. You do not need to create a class for those java and c #, and then declare fields and attributes. Assign values to attributes after final instantiation.
In JS, you can declare attributes and assign values to each other.
Object data = new Object (); data. ID = "qwert123"; data. Name = "yys"; data. Content = "This is an Object! ";
...
That is to say, you can arbitrarily declare the attributes of your object. Here is what I think is more comfortable to use.
Because js is weak, most of the basic types are var declarations, and objects are objects.

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.