Attach and detach javascript object from object graphs