Q:

How to return all properties and their values of an object including iterable ones, custom ones and inherited ones?

So far, I've learnt:
1) the for loop, I can use to iterate over indices in an object such as an array that has keys that were numeric indices.
2) the for..in loop gives me both iterable and custom properties and inherited properties, too. However, it leaves out properties whose values are undefined.
For e.g.
var array = [ 'Apples', , 'Pear' ];

array.newFn = function () { };
Array.prototype.anotherFn = function() { };
array.foo = bar;

for (var prop in array)
  console.log(prop);

will leave out index 1 because its value is undefined.
It will, however, iterate over newFn, anotherFn and foo.
3) The for..of iterates over values instead of keys. The difference is that it iterates over all iterable properties only, leaving out custom ones and also leaving out those inherited from the prototype chain. In doing so, however, includes those values where either the property key or the property value or both have the value undefined. Again, it includes this only for the iterable, own properties of the object.
Is there a looping construct that iterates over:

All iterable properties; and
Custom ones; and
Those inerhited from prototypes all the way down?

And iterates over the keys? Once I have the keys, I can get the values.
If there isn't an in-built looping construct, there must be some reflective property on Object named keys or some such that lets me peek into it?

A:

The simplest approach would be to set the index to undefined using void. You can alternatively use null.

var array = [ 'Apples', void 0, 'Pear' ];

array.newFn = function () { };
Array.prototype.anotherFn = function() { };
array.foo = "bar";

for (var prop in array)
  console.log(prop);

