Node.js is a platform built on Chrome's JavaScript run time for easily building fast and scalable network applications.
We can run javascript code on the server.
Why Node Js?
Node.js operates on a single-thread, using non-blocking I/O calls, allowing it to support tens of thousands of connections held in the event loop. and it also memory efficient.
Node Js Module
Module in Node.js is a simple or complex functionality organized in single or multiple JavaScript files which can be reused throughout the Node.js application.
Type of module:
3 types module
a:File based module : we have export the file module like module.export and import that file module using required function.
b:Core module:Built in module ( its already in built)
c:External node module: node package manager (API) using npm commmand
Node REPL
REPL stands for Read-Eval-Print-Loop. It is a quick and easy way to test simple Node.js/JavaScript code.
# How to write hello world in node
How to exit node repl ?
=> Press 2 times Ctrl +C
How to install node js
Step 1 : Create a folder in drive using cmd promt
in that folder install node js , using cmd ==> npm init
After Complete open folder in sublime text editor => package.json
Create index.js file then create Hello World
Run the Program in cmd just write node and file name
# demo 1
How to calculate area and perimeter
out put
# demo2 Find area and perimeter using File Based Module
step1 : create new file square.js ==> pest the code using exports
step2 : import the file in index.js so we are using require
step3: output ==> go to cmd and type node index
No comments:
Post a Comment