Data type of JS

Source: Internet
Author: User

JS data types are divided into primitive types and object Types

The original type is divided into: null,undefinded, string, number, bool;

Where null and undefinded are values that cannot have a method, and string, number, BOOL can also have its own method.

null,undefinded, string, number, bool are immutable types, and no method can change a primitive value.

object Types are divided into: array,function (), regexp,date

Array,function (), regexp,date can have their own methods.

Array,function (), regexp,date are mutable types.

null and undefinded: Both null and undefinded are worth the vacancy, usually interchangeable

Where typeof null returns the String object, and typeof undefinded returns the string undefinded

Wrapper object : String,number,bool are not objects but can all refer to methods and properties as objects

In string, for example, when a string is called on a property of string, JS converts the string to an object by calling new string (s), and the object inherits the methods and properties of the string, once the reference knot

The newly created object will be destroyed. The temporary object created is called the wrapper object. The modification of a property occurs only on the temporary object, and the temporary object is not saved.

immutable primitive values and mutable Object references : The original value is immutable, no method can change or mutate a primitive value, and the value of the object is mutable, and its value is modifiable.

All methods in the string appear to return a modified string, in effect returning a new string value.

Data type of JS

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.