JS basic syntax and variables

Source: Internet
Author: User

1.//declares a variable, JS is a weakly typed language, and the variable type is explicitly meaningless. Variable types can be changed at any time.
var a = 1;
A = "haha";
A = false;
2. Comments are the same as Java (//and/**/), but there is no document comment.
3,js each line of statements using ";", can also not add, but it is better to add it.
4. Declaring variables is, or can not add Var, plus var declaration, the scope of the code block, not add is the global scope.
5. Syntactically is case-sensitive.
6.
Classification of variables in Java
* Basic Data type ==>8 (4 integer, 2 floating point, 2 characters)
* Reference Data type
Variable classification in JS:
* Primitive type (simple data stored in stack)
* Object type (objects stored in the pair (heap))
Primitive type ==>5 species
1.number digits, partial integer or floating-point type.
2.string string
3.boolean Boolean
4.null average person is assigned null, placeholder for object type
5.undefined (undefined/uninitialized), a null derivative, usually automatically assigned by the system, when we create a variable, and there is no initialization.
Operator ==>typeof returns the type name of the original type
var a = "Hello";
Alert (typeof a);
typeof null returns an object. This is a JavaScript bug, and later felt very good, it was preserved.
var B = new Object ();
typeof B; This is also the object returned

JS basic syntax and variables

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.