Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

has-tostringtag 1.0.2

Determine if the JS environment has `Symbol.toStringTag` support. Supports spec, or shams.
Package summary
Share
0
issues
0
licenses
Package created
5 Aug 2021
Version published
1 Feb 2024
Maintainers
1
Total deps
0
Direct deps
0
License
MIT
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does has-tostringtag do?

"has-tostringtag" is a JavaScript utility function that helps developers identify if the JavaScript environment they are working in supports Symbol.toStringTag. The Symbol.toStringTag feature is critical in defining a user-defined string value in a JavaScript object's default description. The acknowledgement of a valid Symbol.toStringTag support ensures functions like Object.prototype.toString can provide expected results. It can identify both spec-compliant symbols and shams (pseudo implementations).

How do you use has-tostringtag?

You can use "has-tostringtag" package easily in your JavaScript project. To get started, first install the has-tostringtag package with npm by running npm install has-tostringtag. Once the package is installed, you can require it in your JavaScript file and use it as shown in the following code sample:

var hasSymbolToStringTag = require('has-tostringtag');

// to check if the environment has native Symbol.toStringTag support
if(hasSymbolToStringTag() === true) {
    // Your code here if the environment supports Symbol.toStringTag
} else {
    // Your code here if the environment does not support Symbol.toStringTag
}

// For checking the support of Symbol.toStringTag sham
var hasSymbolToStringTagKinda = require('has-tostringtag/shams');
if(hasSymbolToStringTagKinda() === true) {
    // Your code here if the environment supports a Symbol.toStringTag sham
} else {
    // Your code here if the environment does not support a Symbol.toStringTag sham
}

Please note that "has-tostringtag" provides two kinds of checks: one for the native Symbol.toStringTag support which is not poly-fillable, not forgeable, and another for Symbol.toStringTag sham that mostly follows the spec.

Where are the has-tostringtag docs?

The "has-tostringtag" documentation can be found in the README of the npm package page here. The README provides an overview of the package's purpose, an example of how to use it, and information on supported Symbol shams. It also gives a brief guide on how to launch tests if required. For more robust information regarding the JavaScript Symbol.toStringTag property, developers can refer to the ECMAScript specification as well as the comprehensive documentation provided by Mozilla Developer Network (MDN).

All Versions