Added js function formatObject.