0

fromCharCode MDN

chrome devtool

firefox devtool

I think these output should be the same.according to https://asecuritysite.com/coding/asc2.

But it displays output differently on different browser.why?

Also it's bad for code like fromCharCode running on multiple browser.Function's output is likely different from what you expect.How to prevent it?

codenoobforreal
  • 101
  • 1
  • 5
  • 2
    The result is always the same character. How it is displayed in the console (or the DOM) doesn't really matter. – Andreas Dec 03 '21 at 09:57
  • 1
    How did you get `" "` from 0x12, I'm getting the empty string `""` ..? – Teemu Dec 03 '21 at 10:10
  • @Andreas I think browsers are respect to the standard,there is no argument.But why they display the value like that.Anyway thank you for answering me. – codenoobforreal Dec 03 '21 at 11:22
  • 2
    _"I think browsers are respect to the standard"_ - That would be good, but IE, Safari, ...; _"why they display the value like that"_ - Because the author of that part of function thought it would be a good format for a white-space character when logged in the console. – Andreas Dec 03 '21 at 11:24
  • @Teemu the MDN screenshot is captured by the latest chrome.I have no idea about the empty string. – codenoobforreal Dec 03 '21 at 11:25
  • @Andreas this one convinced me a lot.ty! – codenoobforreal Dec 03 '21 at 11:28

0 Answers0