fails on null values
Closed this issue · 1 comments
Deleted user commented
Thanks for the code.
In the replacer function, "value" might be "null", which converts to "object" with "typeof". Thus accessing "name" fails. =>
if (value != null && typeof value == "object") {
abhishekcghosh commented
Thank you lambdor for pointing this out!
This issue can be easily seen to arise when the node chain passed to cyclicStringify()
is actually acyclic in nature.
The code has been modified with your suggested change on line #21, 44, 48 to handle this.
Also added both cyclic and acyclic node chain test cases in runDemo()
to test this.