This post is more related with the question asked here. Execute JavaScript code stored as a string
but my problem seems little different here.
When I am trying to execute code like this, it errors out unexpected token '<'
setTimeout('<script>console.log("some string")</script>', 1);
Facing same issue with new Function( '<script>console.log("some string")</script>' )
let incomingString='<script>console.log("some string")</script>';
let f = new Function(incomingString.replace("<script>","").replace("</script>",""));
f();
Thiw code on Node outputs: some string but it can't run on snippet
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.