jjzjj

toSource

全部标签

javascript - uneval() 和 .toSource() 有什么区别

uneval(...)和.toSource()有什么区别?ThetoSource()methodreturnsastringrepresentingthesourcecodeoftheobject.Theuneval()methodcreatesanstringrepresentationofthesourcecodeofanObject. 最佳答案 一个接受参数,另一个不接受。这似乎是唯一的区别,尽管不鼓励同时使用两者。uneval(object);Object.toSource();obj.toSource();https://

javascript - 在 Internet Explorer 中实现 Mozilla 的 toSource() 方法

有人为InternetExplorer和其他非Gecko浏览器实现了Mozilla的Object.toSource()方法吗?我正在寻找一种将简单对象序列化为字符串的轻量级方法。 最佳答案 请考虑以下事项:(使用FireFox3.6时)javascript:x=function(){alert('caveatcompter')};alert(['JSON:\t',JSON.stringify(x),'\n\ntoSource():\t',x.toSource()].join(''));显示:JSON:toSource():(func