I was recently trying to use diff to compare output from a library that makes use of Object.create(null). This seems valid (if not encouraged) in some situations, but diff was throwing as the typeof this is 'object' and it is !== null but obj.hasOwnProperty does not exist.
Instead, use Object.prototype.hasOwnProperty.call(obj, key) similar to the way that Object.prototyope.toString is used elsewhere in this library.
Addresses https://github.com/kpdecker/jsdiff/issues/492
I was recently trying to use
diff
to compare output from a library that makes use ofObject.create(null)
. This seems valid (if not encouraged) in some situations, butdiff
was throwing as thetypeof
this is'object'
and it is!== null
butobj.hasOwnProperty
does not exist.Instead, use
Object.prototype.hasOwnProperty.call(obj, key)
similar to the way thatObject.prototyope.toString
is used elsewhere in this library.