2

I'm relatively new to ClojureScript and having never worked in a lisp-like language before, I must say that the documentation is rather... lacking. I just want to transform the following JavaScript statement into ClojureScript:

var obj = new namespace1.namespace2.SomeObject();

I know that you can create new instances of an object in cljs by writing something like

(SomeObject.)

but trying

(def obj (namespace1/namespace2/SomeObject.))

didn't compile. What should I be doing instead?

1 Answer 1

4

Have a look at this answer, it is exactly the same question:

https://stackoverflow.com/a/23653459/1400662

Pasted here:

Using js/a.b.c.d is a bad practice and is likely to break in future versions of the compiler (because it is not a clojure compatible version of interop from what I know)

The good way would be:

(def LatLng (.. js/google -maps -LatLng))

(LatLng. 100 100)
Sign up to request clarification or add additional context in comments.

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.