Socket
Socket
Sign inDemoInstall

is-primitive

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-primitive

Returns `true` if the value is a primitive.


Version published
Maintainers
1
Install size
4.06 kB
Created

Package description

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

Readme

Source

is-primitive NPM version Build Status

Returns true if the value is a primitive.

Install with npm

npm i is-primitive --save

Running tests

Install dev dependencies.

npm i -d && npm test

Usage

var isPrimitive = require('is-primitive');
isPrimitive('abc');
//=> true

isPrimitive(42);
//=> true

isPrimitive(false);
//=> true

isPrimitive(true);
//=> true

isPrimitive({});
//=> false

isPrimitive([]);
//=> false

isPrimitive(function(){});
//=> false

Author

Jon Schlinkert

License

Copyright (c) 2014-2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb-cli on March 16, 2015.

Keywords

FAQs

Last updated on 17 Mar 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc