I have the following string named abc (which consists of javascript variables declarations):
var abc = `
var exp = 'test';
var test = 15;
var test2 = "wow";
`;
I would like to get the value of exp
, test
, test2
from this string.
One of the methods that might work is:
eval(abc);
However this solution is not suitable in typescript for security purposes, what other methods would you recommend ( feel free to propose some npm libraries) ?