2
votes

When I use [] the expression gets compiled to cljs.core.PersistentVector.EMPTY which looks like all expressions of [] map to the same object.

I've read that I shouldn't use new Array(). Is that still worth following?

Since I'm going to call aset on this Array, I need a new object with each call. How would I do that?

2
Probably with some code even if it is JS we can help you see the idiomatic way in clojurescript better - Joaquin

2 Answers

7
votes

There’s pretty neat notation in ClojureScript nowadays. You can just type #js [] and compiler will treat it as native JS array. Works with objects too, like so: #js {:one 1 :two 2}. Such thing will be compiled to bare JS object.

4
votes

Unless you are doing JavaScript interop you should just use persistent vectors. If you really need to make an array you can do so with (array).