Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
Why var value is being updated in a function that only updates the parameter? - Job Application test Question

Here, i have some doubts with this piece of code i found in a job application test i made a few hours ago.

function foo(x){
    x['key'] = "new value"
}

var a = {'key': "old value"}

foo(a)

console.log (a)

Why is the a.key being updated when im just asigning a new value to the function parameter not to the global var?

Fiddle JS: https://jsfiddle.net/SoujiCode/gu2xcwe6

about 4 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 Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!