A package acquisition variable exact function of the type

function gettype(obj) {
  var type = typeof obj;

  if (type !== 'object') {
    return type;
  }
  // If the data is not the type of object, it can be judged directly typeof

  // If the object is a data type, the type must be used to accurately determine Object.prototype.toString.call (obj) way to judge
  return Object.prototype.toString.call(obj).replace(/^\[object (\S+)\]$/, '$1');
}

Guess you like

Origin www.cnblogs.com/nxmxl/p/11688322.html