Skip to content

#4 πŸ›‘ How to run JavaScript using NodeJS

Adarsh Tripathi edited this page Jul 25, 2021 · 1 revision

*****************************Tutorial Start πŸ”₯ ********************************

1. How to Install and Download Node.Js?

Download Node.Js herehttps://nodejs.org/en/download/


2. Node.js Code Practice:1

Run and Test your javascript code on outside of browsers by using node.js on command shell or powershell both:

<script> // C:\Users\adarsh>node // Welcome to Node.js v14.7.0. // Type ".help" for more information. // > var x=45 // undefined // > var y=36 // undefined // > var sum=x+y // undefined // > // > console.log(sum) // 81 // undefined // > </script>

But the alert function are not run on command shell message show "uncaught type error: alert is not defined" because command shell are not showing windows.

  • Type .help on command shell for more information what you can do on shell.

Node.js Code Practice:2

Run and Test your javascript code on outside of browsers by using node.js on command shell or poweshell both:

<script> //going to execute javascript code using node.js console.log("This is my file"); var x=55; var y=65; //concatenate method //console.log("sum of x and y is " + (x + y)); //console.log("Thankyou for you time....!!!"); //output // D:\JavaScript-Tutorial-Crash-Course>node lecture4.js // This is my file // sum of x and y is 120 // Thankyou for you time....!!! </script>

*****************************Tutorial End πŸš€ ********************************

Clone this wiki locally