The original type and reference type of JavaScript

Source: Internet
Author: User

The original type exists in the heap, the reference type exists in the stack, and the reference type is a pointer to the memory of the object.

There are 5 primitive types :Undefined, Null, String, Boolean,number.

JavaScript provides a typeof method to determine the value type, and the result of the original type is undefined,object, String, Boolean, number (typeof null The result is object, which is a historical error but is used as a habit, and the result of the reference type is object.

reference types are generally understood as classes, and object can be said to be the base class for all classes. The class is not explicitly present in JavaScript and is called an object. Other such as a String object, a Boolean object, a number object.

Object objects

    • Property

1.constructor Constructors

var New Object (); alert (obj.constructor); Result: function Object () {    [native code]}

2.Prototype

    • Method

1.hasOwnProperty (property) Whether there is an attribute

2.IsPrototypeOf (object) is another object prototype

Whether the 3.PropertyIsEnumerable property can be for...in enumerated

4.ToString () returns the string representation of an object

5.valueOf () returns the original value that best fits the object. Most of the time, the same as the ToString () result

The original type and reference type of JavaScript

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.