type-is-object

A utility to check if value is not null and its type is object.

Installation

Using npm

npm i type-is-object

Usage

In Node (CommonJS)

const isObject = require('type-is-object');

// on "undefined" -> false
console.log(isObject());

// on "null" -> false
console.log(isObject(null));

// on "number" -> false
console.log(isObject(100));

// on "string" -> false
console.log(isObject('foo'));

// on "boolean" -> false
console.log(isObject(true));

// on "plain object" -> true
console.log(isObject({ a: 100, b: 200 }));

// on "array" -> true
console.log(isObject([1, 2, 3]));

// on "function" -> true
console.log(
  isObject(function() {
    return 'bar';
  })
);

In the Browser (ES6 modules):

import isObject from 'type-is-object';

Contributing

If you find any issues, feel free to submit a pull request

Author

iClusterDev

License

This project is under the MIT License