Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

124
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda