Search code examples
javascriptvisual-studiointerpreterinteractive-modevisual-studio-code

Is there an "immediate window" in Visual Studio Code to run Javascript?


Yes, I use F12 in the browser all the time to test out Javascript snippets with the console. I'm tired of that (for the moment anyway).

I've read that in Visual Studio you can use the immediate window to run Javascript interactively.. I've haven't tried it that hard. I think when I did it told me it can't evaluate while in design mode... ugh, what a pain.

I do like to use Visual Studio Code (sublime text historically) sometimes to just mess around with syntax of snippets. Would also be nice if I could just run Javascript there too quickly. Is there a package I could download in VSCode to do so? Or something already built in?


Solution

  • There is no Immediate Window unlike Visual Studio in VSCode. But you can still execute Javascript in VSCode.

    Install the Code Runner Extension - https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner

    Open the JavaScript file in VSCode, then use shortcut Ctrl+Alt+N, the code will run and the output will be shown in the Output Window.