JS Learning Notes

Source: Internet
Author: User

1. Variables1.1 Duplicate statements and omissions of statements

The variable declared by Var is permanent, so deleting the variable with the delete operator will make an error;

Declaring a variable multiple times with VAR is not only legal, but it does not cause any errors. If a duplicate declared variable has an initial value, it is equivalent to assigning the variable a value;

If you attempt to assign a value to an undeclared variable, JS implicitly declares the object, and the implicitly declared variable is a global variable, although it is best to use VAR to create the global variable or the local variable;

1.2 Scope of variables (scope)

The scope of the global variable is global, and the scope of the local variable is local. Inside the function body, the local variable takes precedence over the global variable. If you define the parameter name of a local variable or function to be consistent with a global variable, the global variable will be effectively hidden;

JS does not have block-level scope;

1.3 Basic types and reference types

Base types: Numeric, Boolean, NULL, and undefined values;

Reference types: Arrays, objects, functions;

Base type, a number is 8 bytes in memory, and a Boolean is 1 bytes. However, unlike reference types, they are not fixed in length, so they cannot be directly present in eight-byte memory as the base type. Instead, the storage of a variable is a reference to the value, usually referred to as a pointer or memory address. Although the reference is not the data itself, but he will tell you where to find this value;

1.4 Useless storage units

The collection of useless storage units is automatic;

JS Learning Notes

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.