1

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 ?

2

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your answer. Reading further it appears that (for testing purposes) you can emulate certain aspects of the browser as well in node.js using jsdom.
@CroGo, Yeah, but this will be different from actual browser implementation. Also, you cannot probably use window.alert() window.open() click mouseover listeners etc within the node term.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.