简体   繁体   中英

How to run javascript snippets in firefox/chrome from a script

I am currently trying to learn javascript. Coming from a python/R background I find it really useful for learning purposes to be able to write code in a script in Rstudio/pyCharm which I can then execute in a interpreter by highlighting specific lines of code and then pressing a ctrl+enter or some other keyboard shortcut.

The console available on firefox/chrome seems incredibly rich and useful for learning / testing specific pieces of code but I find it quite limiting that I can't store each line in a script with comments/notes to myself.

Is there a way to run lines of javascript in firefox/chrome like pycharm & rstudio can with their respective interpreters or how is it usually recommend for people to learn the language in an efficient manner ?

Use node.js which is a javascript runtime using v8 (powering the chrome console) You can get an REPL similar to Python.

You cannot, however use it to modify the DOM or access the window. In such case, using an online IDE like jsfiddle or codepen might be a good alternative.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM