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

fjl-typeof

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fjl-typeof

Values type name getter.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

fjl-typeof

Strict typeof implementation. Gives you a value's type name.

Usage

typeOf(x)

Returns a value's "type" name; E.g. (value).constructor.name else for null returns Null; for undefined returns Undefined; for NaN returns 'NaN'; for every other value type returns their type's name (functionality includes the likes of Symbol all native javascript constructors and includes userland ones).

Params:
  • x - Some value to get type name of.
Returns:

A string representing the type's name; E.g., typeOf("hello") === 'String'

#####Examples:

typeOf('hello') === 'String'
typeOf(99) === 'Number'
typeOf(0 / 0) === 'NaN'
typeOf(Symbol('hello')) === 'Symbol'
typeOf(null) === 'Null'
typeOf(undefined) === 'Undefined'
etc..

Motivation

  • Javascript doesn't have a built-in, all-around type checker. This function allows one to build one.
  • Is a more robust alternative than using the native typeof since it gets type names of all native and userland types.
  • Very useful in-cases where many type checks are necessary (long logical (switch, if) control statement chains etc.).

Pre-requistes

Ecmascript 5+

Installation

  • npm install fjl-typeof or
  • yarn add fjl-typeof

License

BSD 3

FAQs

Package last updated on 10 Jan 2018

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