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

160
Vistas
Different `String` function behavior in Chromium and Safari

If you run the following code in the browser console, then you get different results in Chromium and Safari.

String(function() { <!--
}).length

Chromium returns:

19

Safari returns:

20

Why?

Note 1

Running via the StackOverflow code editor will deliver the same output, regardless of browser, probably due to the various levels of mediation between the raw output and the browser window.

Note 2

The toString outputs rendered into the console, differ:

Chromium:

'function() { \x3C!--\n}'

Safari:

"function () { <!--
}"

EDIT

This contains a correction of an earlier version of this question that presented incorrect interpretations of the result.

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

0

The reason here is not the different linebreak symbols, but in fact Safari adds a space before the () function parentheses in its syntax. Try this to compare the characters side by side more easily:

String(function() {
}).split("")

You will see that in Chrome, it will write it as

function()

whereas in Safari it becomes

function ().

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