0

It's know that copy is a special function available inside the developer console of Chrome and Firefox (and potentially other browsers) to copy an object to the clipboard. [1][2]

So why is it that when I copy some highly complex object in chrome to debug in my text editor, parts of it revert to calling its toString function, resulting in "[Object object]" when none is specified?

jgawrych
  • 3,322
  • 1
  • 28
  • 38

1 Answers1

0

This problem occurs when the object contains a circular reference. For example:

var foo = {};
foo.bar = foo;
copy(foo);

Chrome (v54) substituting the object with its string value. In Firefox (v47), if the object has a circular references, the error /* TypeError: cyclic object value */ to be copied to the clipboard instead.

jgawrych
  • 3,322
  • 1
  • 28
  • 38