I know, that there are already similar topics on SO, and the answer to them is usually "you can use eval(), but you shouldn't do this". Great answer, but anyway eval() doesn't solve my problem. Let's say I have a String var called string_code:
var GLOBAL_TEST= 'it works';
alert(GLOBAL_TEST);
Now I need to execute it. Note, that it should also define GLOBAL_TEST, so it can be used later on. Using jQuery, I do it like this:
$('body').append('<script>'+string_code+'</script>');
Now, how to do it in pure JS?