What are the pros and cons of using the inspect function in node's util module for checking deep object equality, regarding accuracy and performance? I believe it is at least more comprehensive than JSON.stringify()
A few node logs below illustrate the superior accuracy of util.inspect over toString() and JSON.stringify():
> ([1,2, undefined]).toString()
'1,2,'
> ([1,2,null]).toString()
'1,2,'
JSON.stringify([1,2,null])
'[1,2,null]'
> JSON.stringify([1,2,undefined])
'[1,2,null]'
> require("util").inspect([1,2,undefined])
'[ 1, 2, undefined ]'
> require("util").inspect([1,2,null])
'[ 1, 2, null ]'
> require("util").inspect([1,2,"null"])
'[ 1, 2, \'null\' ]'
But I'm concerned about any gotchas, and also the performance ramifications.