Convert Javascript Object (incl. functions) to String

后端 未结 10 1032
你的背包
你的背包 2020-12-29 21:35

Hey, Im trying to convert specific javascript objects to a String. So far I\'m working with json2.js. As soon as my Object contain functions, those functions are stripped. I

10条回答
  •  北海茫月
    2020-12-29 22:01

    Use String() function http://www.w3schools.com/jsref/jsref_string.asp

    var f = function(a, b){
        return a + b; 
    }
    var str = String(f);
    

提交回复
热议问题