Node JS Exam Latest Updated Graded A+
.pipe() - ANSWER-a function that takes a readable source stream and outputs to a
writable stream
are for loops and async callbacks compatible? - ANSWER-not really, need to use
recursion instead
async.forEachSeries - ANSWER-iterates over every element in the provided array,
calling the given function for each
aync.auto function - ANSWER-lets you mix ordered and unordered functions together
into one powerful sequence of functions
can you chain multiple .pipe()'s together - ANSWER-yes
console.assert(cond, message) - ANSWER-if cond evaluates to false, throw an
AssertionFailure exception
create a module that prints out "Hello World" - ANSWER-exports.hello_world = function
() {
console.log("Hello World");
}
exports object - ANSWER-a special object created by the Node module system in every
file you create and is returned as the value of the require function when you include the
module
four core REST operations - ANSWER-get, put, post, delete
fs.readdir(file, callback) - ANSWER-returns all items in the given folder except for "."
and ".."
GET /albums/italy2012.json - ANSWER-the request returns this album
how do you handle a situation where you are losing the this pointer? - ANSWER-
enclose the function within a function, then assign self to this (var self = this;). this
preserves this via closures in function scope
How to load script to Node REPL? - ANSWER-.load foo.js from within Node REPL
If functions return immediately, why doesn't the node process exit immediately after the
function has returned? - ANSWER-Node operates on an event queue; if there are
pending events awaiting a response, it doesn't exit until your code has finished
executing AND there are no events left in the queue
.pipe() - ANSWER-a function that takes a readable source stream and outputs to a
writable stream
are for loops and async callbacks compatible? - ANSWER-not really, need to use
recursion instead
async.forEachSeries - ANSWER-iterates over every element in the provided array,
calling the given function for each
aync.auto function - ANSWER-lets you mix ordered and unordered functions together
into one powerful sequence of functions
can you chain multiple .pipe()'s together - ANSWER-yes
console.assert(cond, message) - ANSWER-if cond evaluates to false, throw an
AssertionFailure exception
create a module that prints out "Hello World" - ANSWER-exports.hello_world = function
() {
console.log("Hello World");
}
exports object - ANSWER-a special object created by the Node module system in every
file you create and is returned as the value of the require function when you include the
module
four core REST operations - ANSWER-get, put, post, delete
fs.readdir(file, callback) - ANSWER-returns all items in the given folder except for "."
and ".."
GET /albums/italy2012.json - ANSWER-the request returns this album
how do you handle a situation where you are losing the this pointer? - ANSWER-
enclose the function within a function, then assign self to this (var self = this;). this
preserves this via closures in function scope
How to load script to Node REPL? - ANSWER-.load foo.js from within Node REPL
If functions return immediately, why doesn't the node process exit immediately after the
function has returned? - ANSWER-Node operates on an event queue; if there are
pending events awaiting a response, it doesn't exit until your code has finished
executing AND there are no events left in the queue