Get the type of an object - Node.js Object

Node.js examples for Object:Object Operation

Description

Get the type of an object

Demo Code

/**//from  ww  w. j  av  a 2 s .  c om
 * Get the type of an object
 *
 * @param  {object} obj Object
 * @return {string}     Type of the object
 */
export default function toType(obj) {
  return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
}

Related Tutorials