Is it possible to have 0x00 byte in the JS code? For example, executing eval(String.fromCharCode(97,61,55,59,0)); in FF, Opera, Chrome fresh versions leads to an error. And in WScript there are no errors. Who is right?

  • WScript is not exactly javascript. In chrome it seems to work, by the way. What error leads to? - Grundy
  • "Uncaught SyntaxError: Invalid or unexpected token" chrome issues. The fact that WScript is not JS is understandable. But I want to understand: in JS this can be or not? - Vladimir Martyanov
  • a similar question but about another character. Apparently the implementation from MS, including EDGE and maybe IE just drop the null character at the end. At the same time, there are no special references to this symbol in the specification. The source code can use any character from UTF-16. But at the same time, the use of special characters outside the lines is very limited. - Grundy
  • one
    In the string, this character is valid, but in the code it is an unknown beast, like a number after the var , therefore there is an error. - user207618
  • @Grundy Looks like MS will allow it not only at the end of the script, but not anywhere, either ... - Vladimir Martyanov

1 answer 1

Suppose in line and in comments

 var x="/*\0*/console.log('hel\0lo')"; console.log(x) eval(x); eval(String.fromCharCode(97,61,55,59,47,47,0)); console.log(a)