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

210
Vistas
How we have a return value of pop() function in JavaScript?

While I was recently studying JS coming from a C++ background, I found out that the pop() function of arrays has a return value in JS.

Now, in C++ we don't have a return value for pop_back() method because according to a paper by Cargill, it is impossible to design an exception-safe stack pop function as answered here

So how are things working in JS or am I missing something?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

None of the "Exceptions Thrown by T" cases pop up in JavaScript, because there simply is no assignment or construction operator invoked. JavaScript is a garbage-collected language, so everything is a handle to the actual object. Calling pop just shrinks the array by one and returns the handle that was there without doing anything more.

If you want to reason about it in terms of C++, everything is a std::shared_ptr<T>, so pop just move-constructs that to its return value, which is exception-free.

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