time-to-botec/js/node_modules/@stdlib/utils/property-symbols-in/README.md
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

2.0 KiB

propertySymbolsIn

Return an array of an object's own and inherited symbol properties.

Usage

var propertySymbolsIn = require( '@stdlib/utils/property-symbols-in' );

propertySymbolsIn( obj )

Returns an array of an object's own and inherited symbol properties.

var symbols = propertySymbolsIn( [] );

Notes

  • In contrast to the built-in Object.getOwnPropertySymbols(), if provided null or undefined, the function returns an empty array, rather than throwing an error.

Examples

var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' );
var Symbol = require( '@stdlib/symbol/ctor' );
var propertySymbolsIn = require( '@stdlib/utils/property-symbols-in' );

var hasSymbols;
var symbols;
var obj;

hasSymbols = hasSymbolSupport();

function Foo() {
    if ( hasSymbols ) {
        this[ Symbol( 'beep' ) ] = 'boop';
    }
    return this;
}

if ( hasSymbols ) {
    Foo.prototype[ Symbol( 'foo' ) ] = 'bar';
}

obj = new Foo();
symbols = propertySymbolsIn( obj );

console.log( symbols );