[Javascript] Object literal toString

Steve Clay sclay at ufl.edu
Tue Mar 14 07:35:31 CST 2006


Tuesday, March 14, 2006, 6:02:32 AM, Laurent Muchacho wrote:
> http://www.be-lovely.com/code_pool/examples/object_literal_toSource.htm

toSource() was added in JS1.3 and apparently never adopted in IE/Opera.

> anyone know a cross browser way to do this.

The JSON.stringify() method might be a good enough approximation of
toSource(). You'll get an eval()-able string of properties, but I don't
know if methods are preserved. Give it a shot.
Info: http://www.json.org/js.html
Script: http://www.json.org/json.js

Steve
-- 
http://mrclay.org/




More information about the Javascript mailing list