← Back to context

Comment by SahAssar

6 hours ago

It really is. There are very few proper use-cases for eval.

For a long time the standard way of loading JSON was using eval.

  • Not that long, browsers implemented JSON.parse() back in 2009. JSON was only invented back in 2001 and took a while to become popular. It was a very short window more than a decade ago when eval made sense here.

    Eval for json also lead to other security issues like XSSI.

    • Problem is, it took until around 2016 for IE6 to be fully dead, so people continued to justify these hacks for a long time. Horrifying times.

  • And why do we not anymore make use of it, but instead implemented separate JSON loading functionality in JavaScript? Can you think of any reasons beyond performance?