Get all gameObjects above selected gameObject

I have a 8 by 8 grid, X and Y axis, of cubes. I would like to find a way to select all cubes above a selected cube into an array. Is there a function in javascript that you can use to see if a gameObject is above an individual?

var i = 0;
for (var y = 0; y < 8; y++) {
    for (var x = 0; x < 8; x++) {
        var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
        cube.AddComponent(Rigidbody);
        i++;
    }
}

For an example, lets say if I click cube 40 I want to select all cubes “physically” above cube #40.

This problem can be very easy, or very difficult depending on what you mean by ‘above’ and the shape of the object. If all your blocks are aligned on the grid positions, you can use Physics.RaycastAll() at any specific grid position:

var ray = new Ray(gridPosition, Vector3.up);
var above = Physics.RaycastAll(ray);

‘above’ will contain an array of RaycastHits, one entry for each object above the specified position.