What is the difference between uneval(...)
and .toSource()
?
The toSource() method returns a string representing the source code of the object.
The uneval() method creates an string representation of the source code of an Object.
One takes a param, the other doesn't. That appears to be the only difference, although the use of both is discouraged.
uneval(object);
Object.toSource();
obj.toSource();
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/uneval https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource
Straight from those sites above:
Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
I'd stay away from this feature. There's likely a better way to accomplish what you're trying to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With