Why there is a difference in behavior for copying contents in primitive and non primitive type?

Primitive & Non-Primitive Data types
Example of copy by value in String data type
Example of copy by reference in array object

--

--

--

Just another techie

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Using the Unity Profiler

Electron is a hulking monstrosity of a WORA framework, and it needs to be replaced.

Docker Entrypoint and ENV Vars

How to convert Excel data into JSON object using JavaScript

The Surprisingly Difficult Task of Printing Newlines in a Terminal

Networking on Azure — Azure Roadmap

What happens when you type gcc main.c?

The Art of Automation Tools — Helm, Operators, Ansible, Terraform

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vamsi K

Vamsi K

Just another techie

More from Medium

Don’t Develop Drunk

null vs. undefined: Can I use only one?

Using Closures To Capture and Modify Primitive Variables in JavaScript

Pass props more easily using the object spread operator