0

How do you run Javascript program like

function foo() {
  alert('foo');
}

foo();

without an html file like you can do in jsfiddle. Can you do that in an editor?

2
  • You could use the terminal in the code editor. Commented Oct 21, 2018 at 19:33
  • Or install NodeJs and run the code from the command line. Commented Oct 21, 2018 at 20:02

1 Answer 1

1

You have several options:

  • Find a Javascript-console plugin for your text-editor or IDE
  • Run your snippet from the console in your browser's developer tools
  • As Andy said, run it from a local NodeJS server

EDIT: If you're on MacOS, this might help you even more: https://www.quora.com/How-do-I-run-my-JavaScript-code-in-Sublime-Text-console

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

Comments

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.