3. Foobarsystem Co.,LTD
What is NodeJS good for?
● Lightweight, networked apps
● Proxies with embedded logic
● Streaming data
● System Scripting
● Evented realtime apps
● Non Blocking I/O: DB, Filesystems
5. Foobarsystem Co.,LTD
Basic Javascript
Types :
❏ primitive are number, boolean, string, null
and undefined
❏ complex are array, function and object
// primitives
var a = 5;
var b = a;
b = 6;
a; // will be 5
b; // will be 6
// complex
var a = [‘hello’, ‘world’];
var b = a;
b[0] = ‘bye’;
a[0]; // will be ’bye’
b[0]; // will be ‘bye’
6. Foobarsystem Co.,LTD
Basic Javascript
Function :
❏ Most importance
❏ When function call this is the global
object
❏ On browser global object == windows
var a = function () {}
console.log(a);
var a = function a () {
‘function’ == typeof a; // true
};
7. Foobarsystem Co.,LTD
Basic Javascript
Closure :
❏ Every time a function is called, a new
scope is define
❏ Variables defined within
a scope are accessible only
to that scope and
inner scopes
var a = 5;
function woot () {
a == 5; // true
var a = 6;
function test () {
a == 6; // true
}
test();
};
woot();
8. Foobarsystem Co.,LTD
Basic Javascript
Classes :
❏ No class keyword. A class define like
function
function Animal (name) {
this.name = name;
}
Animal.prototype.getName () {
return this.name;
};
var animal = new Animal(‘tobi’);
a.getName() == ‘tobi’; // true
9. Foobarsystem Co.,LTD
Basic Javascript
try {} catch {} :
❏ allow to capture an exception
function () {
var a = 5;
try {
a();
} catch (e) {
e instanceof Error; // true
}
console.log(‘you got here!’);
}