Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gettype.js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gettype.js

Better alternative for 'typeof' in JavaScript

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

gettype.js

Build Status

Better alternative for 'typeof' in JavaScript

Install

$ npm i getType.js

Usage

const getType = require('gettype.js');

getType('I am a string');
getType(new String(2019));
// => String

getType(2019);
// => Number

getType([1, 2, 3, 4, 5]);
// => Array

getType({ a: 1, b: 2 });
// => Object

getType(new Set([2, 4, 6]));
// => Set

getType(function() {});
// => Function

getType(true);
// => Boolean

getType(null);
// => Null

getType();
getType(undefined);
// => Undefined

getType(NaN);
getType('n' * 2);
// => NaN

getType(/regExp/);
// => RegExp

getType(new TypeError());
// => TypeError

getType(new Date());
getType(new Date(2000, 3, 5));
// => Date

class TestClass {}

getType(new TestClass());
// => TestClass

License

MIT © Uche Jude

Keywords

FAQs

Package last updated on 10 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc