is-plain-object
isPlainObject(obj)
Attempts to determine if an object is a plain object like those you would create using the curly braces syntax: {}
. The following are not plain objects:
- Objects with prototypes (created using the
new
keyword). - Booleans.
- Numbers.
- NaN.
import isPlainObject from "can-util/js/is-plain-object/is-plain-object";
// Created with {}
console.log( isPlainObject( {} ) ); // -> true
// new Object
console.log( isPlainObject( new Object() ) ); // -> true
// Custom object
const Ctr = function() {};
const obj = new Ctr();
console.log( isPlainObject( obj ) ); // -> false
Parameters
- obj
{Object}
:
Returns
{Boolean}
: