What is node. js?
node. js is the JavaScript language used on the server side.
Its function is like PHP + Apache.
node. JS has built-in HTTP server support.
node. JS follows the modular approach of COMMONJS. HTTP is one of the modules.
node. JS is network-born.
Features of node. JS:
asynchronous I/O and event-driven
node. JS Installation:
Please see: Nodejs
A simple example:
/** Open the editor, enter the following code, save as Helloworld.js to the node installation directory * Open cmd into the node installation directory * Run HelloWorld.js:node helloworld.js * Open the browser, enter the URL: http://127.0.0.1:8080/* Nodejs Example runs successfully*///implementing the simplest HTTP server with node. JSvarHTTP = require (' http ');//invoking the HTTP module provided by node. JSHttp.createserver (function(req, res) {Res.writehead ($, {' Content-type ': ' text/html '}); Res.write (' ); Res.end (' <p>hello World supervisor</p> ');}). Listen (8080); Console.log (' Server running at http://127.0.0.1:8080/');
node. JS Core Module
Global Example:global.console
Common tools util Example:var util = require ("util"); Util.inherits (Sub, Base);
Event Driven events Example:var events = require ("events"); var emitter = new events. Eventemitter ();
File System FS Example:var fs = require ("FS");
HTTP Server var http = require ("http");
Express & MongoDB are useful for Node