Selecting String values
String literals can appear in different statements and locations in JavaScript programs, and when you want to be thorough in your search and don't mind extra noise, (str+)
selects for you all instances of the string literal that can be found.
(str+ [value])
is shorthand for:
clojure
(:or (str \1)
(tpl* \1)
(comp (str \1))
(comp (:ref (str \1)))
(obj (prop (:into (str \1)))))
Which is to say, in English, find me:
- a string of that value
- a template literal whose contents evaluate to that value
- a string of that value placed in a computed property
- a reference to a string of that value placed in a computed property
- an object whose property is a string of that value
And in JavaScript, assuming we search for (str+ "foo")
:
javascript
"foo"
^^^^^
`foo`
^^^^^
`f` + "oo"
^^^^^^^^^^
this["foo"]
^^^^^
let bar = { "foo": 1 }
^^^^^
let foo_ref = "foo"
^^^^^
let bax = { [foo_ref]: 1 }
^^^^^^^