Nvim
Nvim

Reputation: 145

How do you run a Javascript file only without using an html and developer tool?

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?

Upvotes: 0

Views: 86

Answers (1)

Ruben Swieringa
Ruben Swieringa

Reputation: 81

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

Upvotes: 1

Related Questions