Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ JavaScript original values and complex values     - Install Ubuntu text editor KKEdit 0.2.10 (Linux)

- The signature can not be verified under Debian (Linux)

- Oracle how to maintain the consistency of read? (Database)

- Smack 4.1.x Upgrade Guide (Linux)

- CentOS 6.6 install JDK7 (Linux)

- Dual system Linux (Ubuntu) into the Windows NTFS partition's mount error (Linux)

- Lazarus IDE Start Basics Tutorial (Linux)

- Spark and Hadoop comparison (Server)

- MongoDB uses aggregate, group, match mysql achieve in having (count (1)> 1) features (Database)

- Intel Graphics Installer 1.0.3 released, support for Ubuntu (Linux)

- Linux security settings (Linux)

- Oracle Bug caused by the collection of AWR Snapshot fault (Database)

- Cacti Linux-based system monitoring and alarm (Linux)

- Use MongoDB C # MongoDB official driving operation (Database)

- How to configure HTTP Strict Transport Security (HSTS) (Linux)

- Android LayoutInflater source parsing (Programming)

- stat - Get more information than ls (Linux)

- Math objects easily overlooked but very convenient method --JavaScript (Programming)

- Python type way of comparison (Programming)

- Stucts2 values on the page and how the attribute values corresponding to the Action (Programming)

 
         
  JavaScript original values and complex values
     
  Add Date : 2018-11-21      
         
         
         
  In front of the words
 
 javascript data types can be divided into two categories: primitive types and reference types. Primitive types, also known as the basic type or simple type, javascript basic data types include Undefined, Null, Boolean, Number and String five kinds of reference types, also known as complex types in Javascript is Object. Correspondingly, their values are referred to the original value and the value of the complex

characteristic
 
Original value

 The original value is the lowest form Javascript available data or information, or the simplest form. Values of the original type is referred to the original value, because they are not detailed. That is, the numbers are numbers, characters, character, Boolean value is true or false, null and undefined is null and undefined. These values is simplicity itself, can not be represented by the value composed of other values

Complex value

 Complex value can be made up of many different types of javascript objects. Its complex objects in memory size is unknown, because of the complex objects can contain any value, rather than a specific known value

Storage
 
Stack memory

Because the original value of fixed-occupied space, simple data segment, in order to facilitate lifting the query variable speed, which is stored on the stack (stack) in

Heap storage

Since the size will change the complex value, it can not be stored in the stack, otherwise it will reduce variable query speed, so it is stored in the heap (heap), the value stored in the variable at is a pointer to the storage object memory at

Access method
 
Access by value

Original value as a value can not be stored and thinning operations, they will transfer their reference value

var myString = 'foo';
var myStringCopy = myString;
var myString = null;
console.log (myString, myStringCopy); // null, 'foo'

Reference access

A complex value is stored by reference and operations, rather than the actual value. When you create a variable that contains complex objects whose value is a reference memory address. A reference to a complex object, use its name (ie variable or object property) Gets the value of the object referenced by memory address

var myObject = {};
var copyOfMyObject = myObject; // value is not copied, but the copied reference
myObject.foo = 'bar'; myObject // values in operation
// Now, if the output myObject and copyOfMyObject, the output will be foo properties because they refer to the same object
console.log (myObject, copyOfMyObject); // Object {foo = "bar"}

Compare mode
 
 The original value using the value comparison, use complicated reference value comparison. Only when the value is equal to the complex refer to the same object (that have the same address). Even if the object contains the same two variables are not equal, because they do not point to the same object

var price1 = 10;
var price2 = 10;
var price3 = new Number ('10 ');
var price4 = price3;
console.log (price1 == price2); // true
console.log (price1 == price3); // false
price4 = 10;
console.log (price4 == price3); // true
console.log (price4 === price3); // false

 

 

var objectFoo = {same: 'same'};
var objectBar = {same: 'same'};
console.log (objectFoo == objectBar); // false

var objectA = {foo: 'bar'};
var objectB = objectA;
console.log (objectA == objectB); // true

Dynamic Properties
 
For complex values, they can add their properties and methods, you can also change and delete their properties and methods; but the simple values can not add properties and methods

Complex valued support dynamic object properties, because we can define the object, and then create a reference, and then update the object, and all point to the object variable will receive the update. A new variable to point to an existing complex object, not copy the object. This is sometimes referred to as complex values cause value of reference. According to the needs of complex values can have any number of references, even if the object changes, they always point to the same object

var str = 'test';
str.property = true;
console.log (str.property); // undefined

var objA = {property: 'value'};
var pointer1 = objA;
var pointer2 = pointer1;
objA.property = null;
console.log (objA.property, pointer1.property, pointer2.property); // null null null

Package Type
 
The original value is treated as an object constructor creates to use, Javascript will convert it into an object, so you can use the properties and methods of the object, then discard the object properties, and change it back to its original value
     
         
         
         
  More:      
 
- To get Java class / jar package path (Programming)
- Network traffic monitoring ntopng (Linux)
- Advanced Search Oracle study notes (Database)
- The top command under Linux (Linux)
- Linux / Windows setup is complete port range (Linux)
- Django template inheritance child (Programming)
- HA-Federation-HDFS + Yarn cluster deployment (Server)
- The best known for archiving / compression tool under linux (Linux)
- Java static code analysis tool Infer (Programming)
- A command to install Sublime Text 3 on Manjaro / Archlinux (Linux)
- Docker Basic Concepts (Linux)
- Linux performance optimization tools perf top (Linux)
- Ubuntu 14.04 and derivative versions of the user install Pantheon Photos 0.1 (Linux)
- Debian 7.7 Installation and Configuration (Linux)
- OpenSUSE 13.1 OpenSUSE 12.3 and how to install Cinnamon 2.2 Desktop (Linux)
- Mass data storage application of MongoDB database (Database)
- CentOS 7 source code to compile and install Nginx process record (Server)
- Elixir: the future of programming languages (Programming)
- Use of the storage-level replication technology will quickly clone a ASM database to the target environment (Database)
- Make command tutorial (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.