Node.Js

Image

Node.js is an open source cross-platform environment, allowing the execution of JavaScripts on the server side.

It essentially allows you to create dynamic Web pages, but also App. crossplatform, partucularly in the mobile App. development fields.

Code Examples

We start with very simple codes. The more you progress, page after page, the more sophisticated the scripts will be.

C 0001 - Hello World !

Say hello...

console.log("Hello world!");

Reproduce this code, choosing one of the compilers below (♦ See DEF.) (don't copy-paste! It would be too easy). They have the same function, just pick up one according to your preferences.

When you copy your code, replace the existing code (by default) with your own.

Warning ! For some of these compilers, you might have to choose the programming language yourself, in a specific menu which is offered to you. Of course, don't forget to click on RUN !

C 0002 - Event

Configure an event...

var events = require('events');
var eventEmitter = new events.EventEmitter();
var myEventHandler = function () {
  console.log('Il fait beau !');
}
eventEmitter.on('beau', myEventHandler);
eventEmitter.emit('beau');

Reproduce this code, choosing one of the compilers below (♦ See DEF.) (don't copy-paste! It would be too easy). They have the same function, just pick up one according to your preferences.

When you copy your code, replace the existing code (by default) with your own.

Warning ! For some of these compilers, you might have to choose the programming language yourself, in a specific menu which is offered to you. Of course, don't forget to click on RUN !

C 0003 - URL Module

Make the different parts of a URL readable...

var url = require('url');
var adr = 'http://localhost:8080/default.htm?year=2020&month=january';
var q = url.parse(adr, true);
console.log(q.host);
console.log(q.pathname);
console.log(q.search);
var qdata = q.query;
console.log(qdata.month);

Reproduce this code, choosing one of the compilers below (♦ See DEF.) (don't copy-paste! It would be too easy). They have the same function, just pick up one according to your preferences.

When you copy your code, replace the existing code (by default) with your own.

Warning ! For some of these compilers, you might have to choose the programming language yourself, in a specific menu which is offered to you. Of course, don't forget to click on RUN !

Info+

Creation
» Creation date: 2009
* Created by Ryan Lienhart Dahl
* Developed by Node.js Developers

* Written in C ++, C and JavaScript
* Cross-platform
* MIT license

Practical cases

In order to train you, we add small programs every week to this section to keep you up to speed.

CASE 1

BASIC LEVEL

Connect to a server

This set of small programs will get you started with the most important... the very first step.

TRY

CASE 2

INTERMEDIATE LEVEL

Create a database (resource files)

This small kit will allow you to design a database intended to manage a files's library offering different types of resources.

TRY

CASE 3

EXPERT LEVEL

Developing a monitoring module for CRM

Design and develop comments monitoring App., which could be easily integrated into a customer management website.

TRY
2021 (C) Fond of Code tm (protected trademark) - Reflex001 / Diego Piccini (da Todi).
All rights reserved. Protected editorial content (www.theethicalweb.com).

About Us...

About Us...
Reflex001

Web
Programming
Development

Main Topics

Main Topics

Legal/Support

Legal/Support
Image