@stdlib/utils-inherited-property-symbols
v0.2.2
Published
Return an array of an object's inherited symbol properties.
Downloads
5
Readme
inheritedPropertySymbols
Return an array of an object's inherited symbol properties.
Installation
npm install @stdlib/utils-inherited-property-symbols
Usage
var inheritedPropertySymbols = require( '@stdlib/utils-inherited-property-symbols' );
inheritedPropertySymbols( obj[, level] )
Returns an array
of an object's inherited symbol properties.
var symbols = inheritedPropertySymbols( [ 1, 2, 3 ] );
By default, the function walks an object's entire prototype chain. To limit the inheritance level, provide a level
argument.
var symbols = inheritedPropertySymbols( [ 1, 2, 3 ], 1 );
Examples
var hasSymbolSupport = require( '@stdlib/assert-has-symbol-support' );
var Symbol = require( '@stdlib/symbol-ctor' );
var inheritedPropertySymbols = require( '@stdlib/utils-inherited-property-symbols' );
var hasSymbols = hasSymbolSupport();
function Foo() {
if ( hasSymbols ) {
this[ Symbol( 'a' ) ] = 'b';
}
return this;
}
if ( hasSymbols ) {
Foo.prototype[ Symbol( 'c' ) ] = 'd';
}
var obj = new Foo();
var symbols = inheritedPropertySymbols( obj );
// e.g., returns [ Symbol(c) ]
See Also
@stdlib/utils-inherited-keys
: return an array of an object's inherited enumerable property names.@stdlib/utils-inherited-property-descriptors
: return an object's inherited property descriptors.@stdlib/utils-inherited-property-names
: return an array of an object's inherited enumerable and non-enumerable property names.@stdlib/utils-property-symbols
: return an array of an object's own symbol properties.@stdlib/utils-property-symbols-in
: return an array of an object's own and inherited symbol properties.
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.