time-to-botec/squiggle/node_modules/@stdlib/symbol/ctor
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00
..
docs feat: add the node modules 2022-12-03 12:44:49 +00:00
lib feat: add the node modules 2022-12-03 12:44:49 +00:00
package.json feat: add the node modules 2022-12-03 12:44:49 +00:00
README.md feat: add the node modules 2022-12-03 12:44:49 +00:00

Symbol

Symbol factory.

Usage

var Symbol = require( '@stdlib/symbol/ctor' );

Symbol( [description] )

Returns a Symbol primitive.

var s = Symbol();
// returns <symbol>

To aid debugging, provide a symbol description.

var s = Symbol( 'beep' );
// returns <symbol>

Notes

  • Unlike conventional constructors, the function does not support the new keyword.
  • The function is only supported in environments which support symbols. In non-supporting environments, the value is undefined.

Examples

var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' );
var Symbol = require( '@stdlib/symbol/ctor' );

var s;

if ( hasSymbolSupport() ) {
    s = Symbol( 'beep' );

    // Print the value type:
    console.log( typeof s );
    // => 'symbol'

    // Serialize the symbol as a string:
    console.log( s.toString() );
    // => 'Symbol(beep)'

    // Test symbol equality:
    console.log( s === Symbol( 'beep' ) );
    // => false
} else {
    console.log( 'Environment does not support symbols.' );
}