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

162
Views
How to set a primitive value without losing object properties in javascript?

Say (for reasons) I'm using object wrappers on primitive values, like this:

var x = new Number (7);
x.source = "never-you-mind";
console.log(x);
// Number {7, source: 'never-you-mind'}

How might I go about changing that primitive value without losing the object properties?

// do magic here
console.log(x);
// Number {777, source: 'never-you-mind'}

Or is it the case that the primitive value is immutable, and I need to construct a wholly new object-wrapped-primitive and then copy those properties across? (Which I'll probably do with a function).

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!