I am building a simple javascript code editor for purposes of training (like codepen without all its functionality). For the same, I am using ace-editor to get the code entered by the student. However, for purposes of executing the code, almost everyone seems to warn not to use eval
or new Function(...)
.
I am expecting the code written by the student to access DOM elements (like canvas etc) of the page.
Any suggestions on the above use case would be welcome. Thanks