JavaScript Learning notes-data types

Source: Internet
Author: User

A data type

Base type: undefined,null,boolean,number,string save in stack memory space fixed variable accessed directly from the stack memory is the value

Reference type: Array,object,function,regexp save in heap memory takes up space an invariant variable reads a pointer from the stack memory and accesses the value in heap memory through the pointer

1. Dynamic Properties

Cannot add property or method to base type

2. Copying variable values

A value type is a variable of a primitive type, a value that is copied, a variable of a reference type, a copy of a pointer, and the same object that they all point to

3. Parameter passing

All function parameters in ECMAScript are passed by value

functionsetName (obj) {obj.name= "Mysic"; }varperson ={};setname (person); alert (person.name)//Mysic//seems to be a reference. In fact, it is still passed by value. //The value here refers to the pointer that the object holds in the stack memory. functionsetName (obj) {obj.name= "Mysic"; Obj= {}; Obj.say= "BlaBla"; }varperson ={}setname (person); alert (person.name)//MysicAlert (Person.say)//undefined//if it is a reference pass, the person should be the new object in the function and the say property exists. does not actually exist.  

4. Detection type

Basic type data with typeof

Reference type data with instanceof Object[,array,regexp]

JavaScript Learning notes-data types

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.