Avoid dots in the name part of symbols. "js/a.b.c" works to reference "a.b.c" by value (i.e. without calling it), but it's not idiomatic. Prefer (.. js/a -b -c), or using your examples:
(.. js/Foo -Bar -Foo2 -myProperty) (.. js/Foo -Bar -Foo2 myMethod) The "js" pseudo-namespace is special because it emits the symbol as normal js property access, but if it were a *real* namespace there would be no dotted symbols in it. (That said, I cheat all the time e.g. with "(js/console.log x)".) On Thursday, August 28, 2014 3:22:53 PM UTC-5, Rafal Spacjer wrote: > Hello, > > I' curious what is a preferable way of accessing properties or methods in > nested JavaScript "namespaces". > > Lets assume that external library define such property: > > Foo.Bar.Foo2.myProperty in global namespace. > > what is idiomatic way of accessing 'myProperty': > > (.-myProperty js/Foo.Bar.Foo2) > > or > > (.. js/Foo -Bar -Foo2 -myProperty) > > Same question for a method, if we have such statement: > > Foo.Bar.Foo2.myMethod(); > > how should we invoke 'myMethod'? Is this correct: (.myMethod js/Foo.Bar.Foo2) > ? -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
