JavaScript variables, scopes, and memory issues

Source: Internet
Author: User

Main content:

  • Understanding the values of basic types and reference types
  • Understanding the execution Environment
  • Understanding Garbage Collection

4.1 Values for base types and reference types

A primitive type value refers to a simple data segment, whereas a reference type value refers to an object that may consist of multiple values. When assigning a value to a variable, the parser must determine whether the value is a base type value or a reference type value.

4.1.1 Properties of the dynamic

For values of reference types, we can add properties and methods to them, and you can change and delete their properties and methods.

4.1.2 Copy variable values

var num1=5;

var num2=num1;

The NUM1 and the 5 in num2 are respectively preserved and independent of each other.

var obj1=new Object ();

var obj2=obj1;

Obj1.name= "Hello";

alert (obj2.name);//"Helo"

Obj1,obj2 is applied to the same object object.

4.1.3 Passing parameters

The parameters of all functions in ECMAScript are passed by value.

4.1.4 Detection Type

JavaScript variables, scopes, and memory issues

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.