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

333
Vistas
Javascript: The interpretation of string comparison code

How does JS interpreter this line: if ("foo"[0] === "f"){}? Two versions I could think of:

Version 1:

JavaScript creates a completely new string object which stores "f". This would require a lot more time than the second option, tho in my opinion this version looks more like JavaScript than the other.

Version 2:

Either JavaScript's lexer or parser converts "foo"[0] to "f". Because we are not talking about initializing or setting the value of a variable, we don't need to store the whole string, and we don't need to create a new string object. The interpreter just simply runs if ("f" === "f") {} .

Which of the 2 versions are the correct one? Is there another version? I'm also happy to read the solutions in other languages.

about 4 years ago · Juan Pablo Isaza
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