aclone

functionsince v0.0-927 clojure.core/acloneEdit
(aclone arr)

Details:

Creates a clone of the given JavaScript array arr. The result is a new JavaScript array, which is a shallow copy, not a deep copy.


Examples:

(def a #js [1 2 3])
(def b (aclone a))
(aset b 0 4)

a
;;=> #js [1 2 3]

b
;;=> #js [4 2 3]

See Also:


Source docstring:
Returns a javascript array, cloned from the passed in array
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn aclone
  [arr]
  (let [len (alength arr)
        new-arr (make-array len)]
    (dotimes [i len]
      (aset new-arr i (aget arr i)))
    new-arr))