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

has-symbols

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

has-symbols

Determine if the JS environment has Symbol support. Supports spec, or shams.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
52M
decreased by-10.32%
Maintainers
1
Weekly downloads
 
Created

What is has-symbols?

The has-symbols npm package is used to determine if the JavaScript environment has native support for ES6/ES2015 symbols. Symbols are a new primitive type introduced in ES6 that enable the creation of unique identifiers for object properties. The has-symbols package provides a simple way to check for symbol support, which is useful for library authors who want to create code that is compatible with both modern and older environments.

What are has-symbols's main functionalities?

Check for native Symbol support

This feature allows you to check if the current JavaScript environment supports ES6 symbols natively. The function `hasSymbols()` returns a boolean indicating the presence of native symbol support.

var hasSymbols = require('has-symbols');

if (hasSymbols()) {
  console.log('Environment has native Symbol support');
} else {
  console.log('Environment does not have native Symbol support');
}

Check for well-known symbols

This feature allows you to check for the presence of specific well-known symbols like `Symbol.hasInstance`, `Symbol.iterator`, etc. The function `hasSymbols(shim)` takes a string argument representing the well-known symbol and returns a boolean indicating its presence.

var hasSymbols = require('has-symbols');

if (hasSymbols('hasInstance')) {
  console.log('Environment has Symbol.hasInstance');
} else {
  console.log('Environment does not have Symbol.hasInstance');
}

Other packages similar to has-symbols

Keywords

FAQs

Package last updated on 02 Dec 2024

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