Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

node.js basic tutorial

branch: master

fixed minor bug

latest commit 933e917a43
Fred Chu fredchu authored
Octocat-spinner-32 callbacks minor change
Octocat-spinner-32 closures init commit
Octocat-spinner-32 events monir change
Octocat-spinner-32 require_and_exports init commit
Octocat-spinner-32 scopes
Octocat-spinner-32 this add readme
Octocat-spinner-32 .gitignore init commit
Octocat-spinner-32 minor change

node.js basics

This is the example codes for the post node.js basics

To run all the example codes please follow the instruction below

require and exports

$ cd /path/to/the/source/require_and_exports
$ node run.js

Function scopes and closures

// scopes
$ cd /path/to/the/source/scopes
$ node run.js

// closures
$ cd /path/to/the/source/closures
$ node run.js

this keyword

$ cd /path/to/the/source/this

// first example
$ node scope.js

// second example
$ node mistake.js


$ cd /path/to/the/source/callbacks

// how other language work
$ node normal.js

// shows you how things go without callback
$ node opposite.js

// how it works with callback
$ node callback.js

// showing the differences of differnet callbacks
$ node alternatives.js


$ cd /path/to/the/source/events/js

// wrong way without callbacks
$ node wrong.js

// right way with callbacks
$ node right.js

// using node.js events
$ cd /path/to/the/source/events/nodejs
$ node run.js
Something went wrong with that request. Please try again.