Generation

generate functionMon, 05 Dec 2022

Get the body of a function as a string

var funcBody = function(func) { return func.toString().match(/\{\s*([\s\S]*)\s*\}/)[1]; } funcBody(function() { return 1; }); // returns 'return 1;'

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant