title: How do I make the eval function safe?
body: <p>I am working on an interactive Canvas tutorial. I want the students to be able to enter JavaScript into a contenteditable element, but I am afraid that it could introduce vulnerabilities.</p>
  
  <p>I have thought about re-assigning dangerous objects or methods before evaluating their code, and then assigning it back afterwards.</p>
  
  <p>How do I determine the dangerous objects?</p>
  
  <p>Is this the right approach, or should I rather scan their input and only allow certain statements?</p>