You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
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
npmnpm
Version published
Weekly downloads
5.7M
30.62%
Maintainers
2
Weekly downloads
 
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

boolean

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