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

135
Views
Does JavaScript support Unboxing or does it only support Autoboxing?

I know that JavaScript support Autoboxing (the automatic conversion from a primitive data type to its object counterpart), but does JavaScript also support Unboxing (the automatic conversion from an object to its primitive data type counterpart)?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

but does JavaScript also support Unboxing (the automatic conversion from an object to its primitive data type counterpart)

Yes it does. This is quite what happens for example when you do:

'' + { };

Which gets you:

'[object Object]'

Although this doesn't exactly fit "Unboxing".

I think a better example would be to use either a String or a Number. Since those are the values that actually get boxed.

new String('test') + '!!!' // "test!!!"
2 ** (new Number(2)) // 4
2 + (new Number(2)) //4
2 / (new Number(2)) //1
about 4 years ago · Juan Pablo Isaza Report

0

The easiest way to obtain the underlying primitive value from an object wrapper is to use the valueOf() method:

 const a = Object(false);
 a == false; //true
 a === false //false
 a.valueOf() == false //true
 a.valueOf() === false //true
about 4 years ago · Juan Pablo Isaza Report
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!