SpinTheMic
Pro

Interview practice question

Code uses eval to evaluate user-provided expressions

Frontend Engineering · JavaScript Core · Experienced

A feature uses eval to calculate formulas entered by users. What are the risks, and what would you do instead?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • eval executes arbitrary code (XSS, data theft).
  • Blocked by strict CSP.
  • Use a safe expression parser.
  • Whitelist operations.
  • Sandbox if code execution truly needed.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics