Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

JS

Mark character strings as literal JavaScript code


Description

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.

Usage

JS(...)

Arguments

...

character vectors as the JavaScript source code (all arguments will be pasted into one character string)

Author(s)

Yihui Xie

Examples

library(htmlwidgets)
JS('1 + 1')
list(x = JS('function(foo) {return foo;}'), y = 1:10)
JS('function(x) {', 'return x + 1;', '}')

htmlwidgets

HTML Widgets for R

v1.5.3
MIT + file LICENSE
Authors
Ramnath Vaidyanathan [aut, cph], Yihui Xie [aut], JJ Allaire [aut], Joe Cheng [aut], Carson Sievert [aut, cre] (<https://orcid.org/0000-0002-4958-2844>), Kenton Russell [aut, cph], Ellis Hughes [ctb], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.