property-names

Get all property names of an object including those in the prototype chain

Usage no npm install needed!

<script type="module">
  import propertyNames from 'https://cdn.skypack.dev/property-names';
</script>

README

property-names

Get all property names of an object including those in the prototype chain

installation

// npm
$ npm install property-names

usage

var getAllPropertyNames = require('property-names');

var Thing = function(){};
Thing.prototype.describe = function(){};

var Vehicle = function(){};
Vehicle.prototype = Object.create(Thing.prototype);
Vehicle.prototype.drive = function(){};
Vehicle.prototype.describe = function(){};

var Car = function( brand ){ this.brand = brand; };
Car.prototype = Object.create(Vehicle.prototype);

getAllPropertyNames(new Car()); // [ 'brand', 'drive', 'describe' ]

License

MIT