JavaScript notes and Summary (2-2) JavaScript variables

Source: Internet
Author: User

JS variable names can consist of _, number, letter, $, and cannot start with a number. A global variable of $ is defined in JQuery.

Declaring variables with var variable names, if not Var, will contaminate the global.

JS variable types include:

① Numeric type

② String Type

③ Boolean type (True,false)

Null type

var a = null

Object type not defined: null

var c = {Name:dee, age:29}//Object type

Console.log (C.name);

Console.log (c[' name ');

undefined type

var b = undefined;

Primitive types (numeric, string) are not defined: undefined

For example: Find a P tag on the DOM and return null (because the DOM is interpreted as a rendered object in the browser)

⑥ Array type (the array's keys increment from 0, and if a pair of key values is deleted, the index of the array is immediately rearranged)

var arr = [' A ', 1,true];

Console.log (arr);

Console.log (arr[2]);

JavaScript notes and Summary (2-2) JavaScript variables

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.