This function JS()
marks character vectors with a special class, so
that it will be treated as literal JavaScript code when evaluated on the
client-side.
JS(...)
... | character vectors as the JavaScript source code (all arguments will be pasted into one character string) |
---|
Yihui Xie
#> [1] "1 + 1" #> attr(,"class") #> [1] "JS_EVAL"#> $x #> [1] "function(foo) {return foo;}" #> attr(,"class") #> [1] "JS_EVAL" #> #> $y #> [1] 1 2 3 4 5 6 7 8 9 10 #>JS('function(x) {', 'return x + 1;', '}')#> [1] "function(x) {\nreturn x + 1;\n}" #> attr(,"class") #> [1] "JS_EVAL"