🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
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
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
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

typeof

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