Linked Questions

50 questions linked to/from Execute JavaScript code stored as a string
-4 votes
1 answer
666 views

I want to run javascript codes from ajax response. For example, I want to show the result via a modal. If I use eval() function, will there be any security issue?
0 votes
5 answers
228 views

I wanna basically execute a statement stored in a var. For example, I have this, var statement = "alert('Hi!')"; How can I make JS execute the statement stored inside the var statement? Thanks a lot ...
0 votes
0 answers
406 views

In JS or Jquery, is it possible to convert a string into a function, and run it ? Something like this : var s = 'var n = 0; n++; alert(n)'; convertStringToFunction(s); // this would show an alert ...
delphirules's user avatar
  • 7,780
-2 votes
5 answers
363 views

Is there any 'code/function/algoritm' to convert the javascript string?: var alert = "alert('Hello World!')"; In javascript syntax; in this case, it would display Hello World! on the screen.
-1 votes
2 answers
92 views

I have the situation that I retrieve a function in a string: var function_name = "function Test(value){return value + 1}"; now I want to execute the function and store the value inside a variable so ...
Rotan075's user avatar
  • 2,615
-3 votes
1 answer
141 views

I'm trying to make a discord bot that executes syntax that we give in the server and send the console logs... How can I do that?
0 votes
1 answer
124 views

I'm trying to make a function that runs a specified piece of code forever. How can I do this? Example: function forever(code) { for (let i = 1; i > 0; i++) { //Run code from variable here ...
0 votes
1 answer
107 views

I want to have a textarea or an input where a user can write javascript code and save it (by clicking a button). Once the code is saved, it is inserted in a script and when the user clicks on "run" ...
George V's user avatar
0 votes
1 answer
96 views

Possible Duplicate: How can I execute Javascript stored as a string? Let us suppose this: var a = 10; var b = 20; var exp = "a+b"; var result = ?; Change the above expression which is string to ...
Talha Akbar's user avatar
  • 10.1k
-2 votes
1 answer
76 views

I have a code saved in string. For eg: const code = "res.send("Hi")"; How can I execute the above code in JS? I wanna execute the code of the code variable. I can't just write code;...
Fat Fatty's user avatar
  • 275
0 votes
1 answer
77 views

To make it more clear, I will put what I want to do in code. var functionsafe = "function plus(a,b){c=a+b; return c}"; and we can directly call function add ()= functionsafe; I wonder if there is a ...
-1 votes
2 answers
38 views

Is it possible to define a function run that acts like this? a = run('var x = 100;') b = run('console.log(x);') // prints 100 c = run('y = 1;') d = run('console.log(y);') // prints 1 ...
user1194032's user avatar
0 votes
0 answers
45 views

I am having a problem where my condition check seems to always be true in the checkConditions function. Click the 'Enter Spins' button and 'Toggle Numberpad' button and add a number. It will display ...
0 votes
1 answer
42 views

i have a string as below and i would like to extract the array between the quotes. mystring = "['str1','str2']" I tried it with eval and i do not want to use eval in my code. is there any ...
0 votes
0 answers
17 views

Is there any way to run a script as a string in JavaScript like this? // core.jslib mergeInto(LibraryManager.library, { myCallback: function (str, arg) { runScript(str, arg); // I want a ...
Spiegel's user avatar

15 30 50 per page
1
2 3 4