JavaScript raw values and object reference instance analysis

Source: Internet
Author: User
Tags arrays comparison

 JavaScript raw values and object reference instance analysis

This article mainly introduces the JavaScript original value and the object reference method, the example analyzes the JavaScript original value and the object reference function, the definition and the related technique, needs the friend to be possible to refer to under

The examples in this article describe JavaScript raw values and methods for object references. Share to everyone for your reference. The specific analysis is as follows:

In a word: The original value is immutable, and the object reference is mutable.

The original values in JS (Undefined, null, Boolean, numeric, and string) are essentially different from objects (including arrays and functions). The original value cannot be changed, and no method can change an original value; for strings, all the methods in the string appear to return a modified string, which actually returns a new string value:


1 2 3 var str= "Hello World"; S.touppercase (); S is still the same

The comparison of the original values is a comparison of values: they want to wait only if their values are equal.

Objects differ from the original values, first they are mutable, and then the comparison of objects is not a comparison of values; objects are compared by reference: they want to wait only if they reference the same base object.

To compare 2 separate objects or arrays, you must compare their properties or elements as follows:


Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.