• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

212
Views
How reference value types in Javascript works?

I'm learning Javascript, based on my knowledge that the reference type like object below is created in the heap, and point to a new piece of memory in the stack. But what happened when I've tried to declare an object like this:

let object = { id: 1223, title: 'test' };

and when I reassigned it:

object = { newId: object.id, newTitle: object.title };

I got:

object = { newId: 1223, newTitle: 'test' };

I'm so curious as to why this is possible, Has the property name gone when I reassigned the object? and How it works behind the screen?

Please give me some explanations, keywords, or documents.

Many thanks.

P/s. Something I forgot is that the = operator's associativity happened from right to left, so the object at this point was not mutated until the execution met the =. Maybe it is the answer for my question somehow.

almost 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error