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

is-primitive

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-primitive

Returns `true` if the value is a primitive.

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is is-primitive?

The is-primitive npm package is used to check if a given value is a JavaScript primitive. A primitive in JavaScript is data that is not an object and has no methods. In JavaScript, there are 7 primitive data types: string, number, bigint, boolean, undefined, symbol, and null. This package provides a simple and straightforward way to determine if a value belongs to one of these types.

What are is-primitive's main functionalities?

Check if a value is a primitive

This feature allows you to check if a value is a primitive type. The function returns true for primitive values and false for objects (including arrays and functions).

const isPrimitive = require('is-primitive');

console.log(isPrimitive(42)); // true
console.log(isPrimitive('hello')); // true
console.log(isPrimitive(false)); // true
console.log(isPrimitive({})); // false
console.log(isPrimitive([])); // false
console.log(isPrimitive(function() {})); // false

Other packages similar to is-primitive

Keywords

FAQs

Package last updated on 10 Jun 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