I have a String that contains a function as a String. This String is returned by the server:
var funcStr = "function() {
console.log('this is a sample function');
}";
Is it possible to parse this String to a Function and execute it?
Yes, it is possible, but not a good idea. You use eval. This isn't the best to do for reasons too complex and opinion-based to get into here.
var fn = eval(funcStr);. Should you do this ever? NO. Also, note the unescaped quotes.