We earn commission when you buy through affiliate links.

This does not influence our reviews or recommendations.Learn more.

JavaScript has been ranked consistently as most developers favorite programming language.

Importance-of-running-JavaScript-in-VS-Code

Over 63% of the respondents interviewed in a2023 Stackoverflow surveysaid they use JavaScript.

On the other hand, Visual Studio code is a popular integrated development environment (IDE).

Visual Studio Code supports JavaScript, among many other languages.

Node version

This code editor also supports TypeScript, a superscript of JavaScript that introduces types.

With Node.js, you might run JavaScrpt outside a surfing app environment.

Node.js has also made it possible to use JavaScript in backend development with its frameworks like Express.js.

VS Code setup

You candownload Node.jsfor free if you dont have it on your machine already.

VS Code supports JavaScript by default.

However, some JavaScript features will need extensions to execute.

isEven

VS Code is free to download.

you might pick the relevantversion for downloadbased on your operating system.

JavaScript is used to add interactivity to websites and is mostly used with HTML and CSS.

isOdd

However, you might also use it for scripting and data structures.

I can now create a simple utility and call it JavaScript-VsCode-app.

This is how our project looks like on the code editor.

Extensions

As you’re able to see, we only have one file (app.js).

I can now write a simple program that checks if a number is even.

I will write my code on theapp.jsfile.

ESLint

However, we need to understand what this code does.

We have a function we have named isEven.

Our function takes a number and returns true if the number is divisible by two.

Code Runner

However, if the number is not divisible by two, it will return false.

After running the code we provided in the last step, we get 8 is even as the output.

What if we check whether 9 is even?

Git version

Add necessary extensions

The program we have created above is simple.

On the left-hand side of the VS Code, choose the second last button.

you’re able to also use keyboard shortcuts:CTRL+Shift+X.

Git init

you’re able to now search for various extensions to use on your code.

For instance, I can search for ESLint.

it’s possible for you to see the extensions are already enabled on my side.

Git status

Always check the description of various extensions to make them easy to configure and use.

Use Code Runner Extension

Visual Studio Code supports hundreds of programming languages.

you might useCode Runnerto execute codes in most common programming languages.

Git add

Locate the extensions tab on the left side of your VS Code and search for Code Runner.

Click install and switch on the extension, and you are now ready to run your code.

I have a simple statement saying console.log(Hello, World!

Git commit

); in my app.js file.

I can run it using Code Runner.

I will use the F1 shortcut and key in RUN CODE.

it’s possible for you to now see all the untracked and uncommitted files.

Run this command:

Replace your commit message with something that describes your actions.

you’re free to now connect your source control with remote repository platforms such as GitHub.

Conclusion

We now hope you understand how to create an environment and run JavaScript in VS Code.

You may need extraextensionsto work with JavaScript libraries and frameworks on this code editor.

However, always keep the Visual Studio Code updated if you want to enjoy all the latest features.

Check out our article on thebest resources to learn JavaScriptand polish your knowledge.