How To Test JavaScript Functions in VSCode

Author: Marty Ballard


Category: VSCode

How to Test JavaScript Functions in VSCode

So oftentimes I'll find myself writing a function for React or Angular and I just want a really quick way to test this function without firing up the app.  Here's a really quck and simple way to do just that.

Create a directory for JavaScript functions, and then a new file for your function.  Copy your function into that new file and then you can simply test it by running it with Node inside VSCode.  You may need to create data to be processed as well, in my case I created an array of objects called data.

After you have the file created, open a terminal right in VSCode from the top menu - Terminal > New Terminal.  Then you simply run the file using node as such -

node <filename>

// example
node array.js

Here's a quck video below to show you how it looks.  I hope this saves you a bit of time.


Post your comment