The Difference Between Values and References in JavaScript

The Difference Between Values and References in JavaScript

In JavaScript, you can pass by value and by reference. The main difference between the two is that passing by value happens when assigning and comparing primitives while passing by reference when assigning and comparing objects.

The main difference between the two is that passing by value happens when assigning and comparing primitives while passing by reference when assigning and comparing objects.

Let’s discuss values and references in more detail in this post.

  1. Understanding primitive and objects JavaScript provides 2 categories of data types: primitives and objects. The primitives are numbers, booleans, strings, symbols, and special values null and undefined.

  2. Values The simple rule of passing by value is that all primitive values in JavaScript are passed by value. Simple as that. Passing by value means that every time you assign a value to a variable, a copy of that value is created. Every single time.

  3. References The pass by references, however, manifests itself differently.

  4. Comparing values and comparing references Understanding the difference between values and references is important when you want to compare objects.

javascript object

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Find Ulimit For user on Linux

Explains how to find ulimit values of currently running process or given user account under Linux using the 'ulimit -a' builtin command.

MEAN Stack Tutorial MongoDB ExpressJS AngularJS NodeJS

MEAN Stack Tutorial MongoDB ExpressJS AngularJS NodeJS - We are going to build a full stack Todo App using the MEAN (MongoDB, ExpressJS, AngularJS and NodeJS). This is the last part of three-post series tutorial.

Creating RESTful APIs with NodeJS and MongoDB Tutorial

Creating RESTful APIs with NodeJS and MongoDB Tutorial - Welcome to this tutorial about RESTful API using Node.js (Express.js) and MongoDB (mongoose)! We are going to learn how to install and use each component individually and then proceed to create a RESTful API.

systemctl List All Failed Units/Services on Linux

Explains how to use the systemctl command to list all failed units or services on Debian, Ubuntu, CentOS, Arch, Fedora, and other Linux distros.

CentOS Linux 8.2 Released and Here is How to Upgrade it

CentOS Linux 8.2 (2004) released. This release adds corrections for security issues based upon RHEL 8.2 souce and here is how to upgrade it.