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

155
Views
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 answers
Answer question

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 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!