This can be done with the toString() function followed by a little parsing to make it look as desired:(这可以通过toString()函数完成,然后进行一些解析以使其看起来像期望的那样:)
//convert to string
var str = jsObject.TestFuntion1.toString();
//parse to make it look like you want:
str = str.substring(0, str.length - 1).replace("function(){", "").trim().replace(/
/g, "").replace(/;s+/, "; ");
//check the result
console.log(str);//"var x = 1; return x;"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…