First knowledge of node. js

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.