
Product
Introducing Module Reachability: Focus on the Vulnerabilities That Matter
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
has-tostringtag
Advanced tools
Determine if the JS environment has `Symbol.toStringTag` support. Supports spec, or shams.
The `has-tostringtag` npm package is designed to check if the environment has `Symbol.toStringTag` support. This is particularly useful for identifying and working with built-in object tags in a way that's consistent with the ECMAScript specification, especially in environments where this feature might not be available or fully implemented.
Checking `Symbol.toStringTag` support
This code checks if the current environment supports `Symbol.toStringTag`. It's useful for determining if you can rely on `Symbol.toStringTag` for identifying object types.
"use strict";\nvar hasToStringTag = require('has-tostringtag');\n\nif (hasToStringTag) {\n console.log('Environment supports Symbol.toStringTag');\n} else {\n console.log('Environment does not support Symbol.toStringTag');\n}
While `core-js` is a much broader polyfill library that includes support for `Symbol.toStringTag` among a vast array of other ECMAScript features, it serves a similar purpose in ensuring environments have access to `Symbol.toStringTag`. Compared to `has-tostringtag`, `core-js` is more comprehensive but also larger in size.
The `es-abstract` package provides utility functions for working with ECMAScript language abstract operations. It includes methods that indirectly relate to `Symbol.toStringTag` by providing a way to work with language internals. Unlike `has-tostringtag`, which is focused on feature detection, `es-abstract` is more about enabling operations that are defined in the ECMAScript specification.
Determine if the JS environment has Symbol.toStringTag
support. Supports spec, or shams.
var hasSymbolToStringTag = require('has-tostringtag');
hasSymbolToStringTag() === true; // if the environment has native Symbol.toStringTag support. Not polyfillable, not forgeable.
var hasSymbolToStringTagKinda = require('has-tostringtag/shams');
hasSymbolToStringTagKinda() === true; // if the environment has a Symbol.toStringTag sham that mostly follows the spec.
Simply clone the repo, npm install
, and run npm test
FAQs
Determine if the JS environment has `Symbol.toStringTag` support. Supports spec, or shams.
We found that has-tostringtag demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
Product
Socket is introducing a new way to organize repositories and apply repository-specific security policies.
Research
Security News
Socket researchers uncovered malicious npm and PyPI packages that steal crypto wallet credentials using Google Analytics and Telegram for exfiltration.