Skip to content
14paxton edited this page Jul 16, 2022 · 6 revisions

get function as string

console.log("1", Function.prototype.toString.call(cloneNodeToDocument))
    console.log("2",cloneNodeToDocument + '')
    const entire = cloneNodeToDocument.toString()
    console.log("3", entire.slice(entire.indexOf("{") + 1, entire.lastIndexOf("}")))
    console.log("4", entire.replace(/^[^{]*{\s*/,'') )
    console.log("5", entire.match(/^[^{]+\{(.*?)\}$/) )
    console.log("6", entire.substring(entire.indexOf("{") + 1, entire.lastIndexOf("}")))
    console.log("7", '(' + cloneNodeToDocument.toString() + ')()')
    console.log("8", '(' + cloneNodeToDocument + ')()')
    console.log("9",extractFunctionBody(cloneNodeToDocument))

Clone this wiki locally