0

I've got a method that return a string like this: enter image description here

I need to extract that javascipt variable, any suggestions ?

Lorenzo Grossi
  • 430
  • 1
  • 5
  • 22
  • 1
    Well, you could use `eval` ...but it's dangerous! https://stackoverflow.com/questions/939326/execute-javascript-code-stored-as-a-string – anotherfred Jun 26 '17 at 14:46

1 Answers1

0

You would need to extract right side of equal sign, and then eval

for example:

var test = "var Admin = ['test1', 'test2']"
var Admin = eval(test.split("=")[1]);
console.log(Admin);
Ramon Marques
  • 3,046
  • 2
  • 23
  • 34