js--understanding of data types

Source: Internet
Author: User

JS variable contains 2 different data types of values

--------------------------------------------------------------------------------------------------------------- ---------------------------------------

1. Basic Type value

The basic type value concept--is a simple data segment, accessed by value, including undefined, Null, Boolean, number, String, without any properties and methods

The basic type value is copied--and a new value is created to replicate without affecting each other, saved in memory, completely independent

The base type value of the-->TYEPOF () can be judged, if it is a reference type (constructor), then return an object

2. reference type value

    The reference type value concept----is an object with multiple values, accessed by reference, mainly constructors (classes), constructed from the new operator, including undefined, Null, Boolean, number, String, And more than one function object, there are corresponding properties and methods

The reference type value is copied--a pointer is copied, and two variables actually refer to the same object (in the subsequent constructor inheritance, if the prototype of the parent class is directly equal to the prototype of the subclass, then the subclass changes will also affect the parent class, The workaround is to have the parent class copy the prototype to the subclass), which is persisted in the heap memory and is an inherited relationship

A reference to the value of a type-->instanceof to determine which data type is referenced

js--understanding of data types

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.