kindOf.js 454 B

1234567891011121314151617181920
  1. var _rKind = /^\[object (.*)\]$/,
  2. _toString = Object.prototype.toString,
  3. UNDEF;
  4. /**
  5. * Gets the "kind" of value. (e.g. "String", "Number", etc)
  6. */
  7. function kindOf(val) {
  8. if (val === null) {
  9. return 'Null';
  10. } else if (val === UNDEF) {
  11. return 'Undefined';
  12. } else {
  13. return _rKind.exec( _toString.call(val) )[1];
  14. }
  15. }
  16. module.exports = kindOf;