Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 806 Bytes

DOTDOT.md

File metadata and controls

54 lines (40 loc) · 806 Bytes
name see also
cljs.core/..
cljs.core/.
cljs.core/->
cljs.core/doto

Summary

Details

For interop, the .. macro allows method/property chaining on the given JavaScript object o.

It essentially combines the thread-first -> macro with the . operator.

Examples

// JavaScript
"a b c d".toUpperCase().replace("A", "X")
//=> "X B C D"
;; ClojureScript
(.. "a b c d"
    toUpperCase
    (replace "A" "X"))
;;=> "X B C D"

This is expanded to:

(. (. "a b c d" toUpperCase) (replace "A" "X"))

which is equivalent to:

(.replace (.toUpperCase "a b c d") "A" "X")
;;=> "X B C D"

Compare to the equivalent form using the thread-first -> macro:

(-> "a b c d"
    .toUpperCase
    (.replace "A" "X"))
;;=> "X B C D"