section: Language, related to: Array * $A(iterable) -> Array * * Accepts an array-like collection (anything with numeric indices) and returns * its equivalent as an actual [[Array]] object. This method is a convenience * alias of [[Array.from]], but is the preferred way of casting to an [[A
(iterable)
| 58 | **/ |
| 59 | |
| 60 | function $A(iterable) { |
| 61 | if (!iterable) return []; |
| 62 | // Safari <2.0.4 crashes when accessing property of a node list with property accessor. |
| 63 | // It nevertheless works fine with `in` operator, which is why we use it here |
| 64 | if ('toArray' in Object(iterable)) return iterable.toArray(); |
| 65 | var length = iterable.length || 0, results = new Array(length); |
| 66 | while (length--) results[length] = iterable[length]; |
| 67 | return results; |
| 68 | } |
| 69 | |
| 70 | /** section: Language, related to: Array |
| 71 | * $w(String) -> Array |
no outgoing calls