2

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?

1
  • Probably with some code even if it is JS we can help you see the idiomatic way in clojurescript better Commented Feb 27, 2014 at 9:31

2 Answers 2

7

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.

Sign up to request clarification or add additional context in comments.

Comments

4

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).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.