Ways to determine if something is a plain object in JavaScript
I've recently stumbled on this function which determines if something is a plain object is JavaScript: function isPlainObject (value){ if (typeof value !== 'object' || value === null) return false; let proto = value; while (Object.getPrototypeOf(proto) !== null) { proto = Object.getPrototypeOf(proto); } return Object.getPrototypeOf(value) === proto; }; Source: https://github.com/redux-utilities/redux-actions/blob/3fa4c50dfeab54fa1f2110764757ee4c10c8e3ac/src/utils/isPlainObject.js I would like to know: If the following approach will do exactly the same stuff? If so, can it be considered more ef
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.