is-plain-object icon indicating copy to clipboard operation
is-plain-object copied to clipboard

Doesn't confirm that the constructor is a function

Open mostekcm opened this issue 3 years ago • 1 comments

I have a plain JS object that is failing the check because it has an attribute called "constructor". But it is defined as a string. This should still be considered a plain JS object.

const myPlainObj = {"code":"invalid_user_password","constructor":"Object","extras":{},"message":"invalid_user_password"};
if (isPlainObject(myPlainObj)) console.log('It is Plain');
else console.log(":(");

https://github.com/jonschlinkert/is-plain-object/blob/master/is-plain-object.js#L17-L19 would likely need to change.

I can create a PR if you'd like.

mostekcm avatar Mar 25 '21 14:03 mostekcm

Okay, I see you have specifically checking for this since pretty much the beginning, and I'm guessing because there are potentially other implications of setting a field called constructor in JSON. Feel free to close this if you'd like. In my use case where I thought I needed this, I have to ignore it anyway because it messes with something else in my framework if you do this.

mostekcm avatar Mar 25 '21 20:03 mostekcm