specification and polyfill for allowing any JavaScript object to function as an array