Hmm, I don't think RStudio can directly run Javascript? You can use RStudio to write Javascript code, to then run it with your web browser.
Or within R, there is the V8 package that provides access to a Javascript engine. This is useful if you need Javascript and R code to communicate. For example:
ct <- v8()
ct$eval("if(true){
let x = 5;
var y = 3;
}
console.log(y)")
#> 3
But overall, if writing pure Javascript, I don't know if RStudio is the best tool?