function/macro | since v0.0-927 | clojure.core/alength | Edit |
(alength array)
For interop, it returns the length of a JavaScript array or string.
(def a #js [1 2 3])
(alength a)
;;=> 3
(.-length a)
;;=> 3
(aget a "length")
;;=> 3
(count a)
;;=> 3
Returns the length of the array. Works on arrays of all types.
(defn ^number alength
[array]
(cljs.core/alength array))
(core/defmacro alength [a]
(vary-meta
(core/list 'js* "~{}.length" a)
assoc :tag 'number))