# Clojure Syntax
What is
::notation in clojure?
Shorthand to use current namespace. :app.client/person --> ::person Localized name
How to define/declare global variables with in namespaces?
def block is like Assignment operator = in other languages
What is the difference b/w
letanddef?
The syntax for them is different, even if the meanings are related.
let takes a list of bindings (name value pairs) followed by expressions to evaluate in the context of those binding. let binds symbols to values in a "lexical scope"
def just takes one binding, not a list, and adds it to the global context.
How to use docs on REPL?
(require '[clojure.repl :refer :all])
doc, find-doc, apropos, source, and dir
What is underscore in reframe?
The underscore is the universal ignore symbol. Its a valid symbol indentifier
(let [_ 1] (println _))
How to add dependency? to manipulate DOM via google closure library?
What is the difference between
:referand:asin cljs declerations?
How to namespce in clojure? (opens new window)
| keyword | description |
|---|---|
:as | as an namespace Alias |
:refer | makes it look like a local function |
What are these clojure keywords?
| macros | what does it do? |
|---|---|
:require | loads a library, function, external code |
:namespaces | mappings from symbols to vars, are first-class and dynamic. Can query ns all-ns. aka Modules |
| SYmbols (opens new window) | Symbols in Clojure are just pieces of data, Clojure uses them as identifiers for various values and references. aka Identifiers |
(defn ^:export init [] (...)) | kick off app when HTML is loaded, same as window.load(callback) |
How to view/list app-db in js console?
app-name.db in js console. Eg: conduit.db
How to convert js arrays and objects to clojurescript data structures?
https://cljs.github.io/api/cljs.core/js-GTclj (opens new window)
what is
.-in js interop?
.- is used to signify field access in Clojure interop, just . is calling a method.
How to reference and use js
thisincljs?
https://clojureverse.org/t/reagent-adding-event-listener-to-a-component/5896 (opens new window) cljs api (opens new window)