Node.js Flashcards
What does Mosh hope we become after this course?
(Hint: Superstar Node developer)
A superstar node developer
Why?
Most comprehensive, most up to date node course
Shows all modern ways to build applications in node
What is node?
an opensource, cross platform
runtime environment for running Javascript code outside browser
Used to build services that power client apps (Web app, Mobile App)

What is node ideal for building?
Highly scaleable, data intensive, real time backed services that power applications
What is so special about node?
(Hint: How is it different from ASP.net, Ruby on Rails, Django)
(faster developement)
Great for prototyping and agile development
(better performance)
Build superfast and highly scaleable backends
Ex. Used by Paypal, Netflix, Uber
(more developers)
anyone with Javascript skills can work as a full stack developer
(cleaner, more consistent source code)
same tools, conventions and best practice (Javascript full stack)
(largest open source ecosystem)
free open source libraries to use

What big tech companies use Node?
(Hint: Uber, Paypal, Netflix, Ebay, NASA)

“We have seen with our proof of concept a tremendous amount of improvement on the response times: for our current APIs we have a steady response of 2 seconds and the Node.js API that we hosted was responding within less than 100 milliseconds. That’s a very promising statistic for us.”
Netflix
node.js app reduced startup time, allowed more movie streaming
Paypal
node.js app outperformed java app on page load times
mobile software stack build solely in Node.js
Yahoo
Node.js has become one of their top technologies
Uber
Node.js into full production allowing quick iterations and zero risks for matching drivers with riders
Groupon
50% reduce in page loading times
GoDaddy
10x less servers thanks to Node.js
Ebay
faster iterations, 175 million users
Walmart
allows fixing bugs much faster
NASA
creating microservices architecture with separate APIs, moving data on astronaut space suits allowing faster queries

What did Paypal find when they rebuild their Java application in node.js?
(Hint: faster, less code, fewer files, faster response time)
An excellent choice for building highly scaleable applications

Where was Javascript run time environment originally?
(Hint: JS engine in browsers)

JS engine converts Javascript code into machine code
Each browser has it’s own JS engine
Ex.
Chrome - v8 engine
Firefox - SpiderMonkey
Internet Explorer - Chakra
Therefore,
sometimes Javascript code behaves differently in different browsers

Why did Ryan Daal embed Chrome’s V8 engine into a C++ program?
V8 engine is fastest Javascript engine
allows us to execute Javascript outside browser
Node.js will convert Javascript code into machine code
gives us additional objects (file system, network, server requests)
What is node.js NOT?
(Hint: Language, Framework)
Not a programming language (C#, Python, Java)
Not a Framework (ASP.NET, Django)
It’s a runtime environment for executing Javascript code!
Provides v8 engine to translate Javascript to machine code
Offers additional objects for working with servers, networks, etc.
What feature of node.js allows it to build highly scaleable, super fast applications?

(Hint: asychronous framework)
Asynchronous
non blocking nature of node.js
ideal for intensive Input/Output apps
ideal for apps that require heavy disk or network access
Why?
Node is continuously monitoring event cue for finished tasks
While event queue is empty, serves additional clients
can serve more clients with less hardware

What should node.js NOT be used for?
(Hint: CPU intensive applications)
Do not use node.js for CPU-intensive apps
video encoding or image manipulation service
Why?
Node is single threaded, while CPU runs, clients must wait
lots of work required by CPU, low requests to file system or network

What should node.js be used for?
ONLY USE for data intensive, real time applications
DO NOT USE for CPU intensive apps
Why?
Single thread get’s caught up with CPU calculations
What core modules in node.js are explored?
(Hint: OS, fs, events, http)
also learn how to create our own modules

What is the global scope object in browsers?
Window
all variables, objects and functions declared globally are accessible in this object

What is the global object in node?
(Hint: global)
variables and functions defined are not automatically added to global scope

in browsers, it is!
Why?
Scoped to their file, because of Node.js module system
Why is it a problem if variables and functions are added to the global scope?
(Hint: maintainable and reliable applications)
Javascript code often split into multiple files
if function is added to global scope
when we define function in another file
definition will override this defintion
Soln?
to build maintainable and reliable applications
create modularity
avoid adding functions and variables to the global object
How can we build maintainable and reliable applications in node?
(Hint: Modules)

Using modularity
modules or files provide abstraction and private members
create small building blocks (modules) where we define variables and functions (encapsulated in module)
variables and functions are scoped to that module (private)
not accessible outside the module unless we export them
Every file in node is a module
Why?
So that variables and functions don’t override eachother

If we want to use a variable or function outside a module, what must we do?
(Hint: export and make public)
Modules provide abstraction
making variables and functions private (not accessible globally)
to use a member defined in a module, must export it

What does every node application have?
(Hint: one module or file)
At least one module or file
Ex. app.js

How do we create and load a module?

Like classes in Java

module.exports
require( )
As a best practice, store module object in a constant
Why?
So we don’t accidentally override it
What is JSHint?
(Hint: Tool for catching compile time errors)
Can scan Javascript for compile time errors

When do we export an object vs. a function in a module?
(Hint: can export object or single function)
Exporting an object is useful if we have multiple functions or properties
(export an object)
module.exports.member = member
(export a single function)
module.exports = member

How does node create a module?

Doesn’t execute code directly
Wraps it inside a function (module wrapper function)

What are some of the useful modules built into node?

Streams
OS - work wit operating system
HTTP - create web servers
file system - work with files
process - get info on current process
query string - usefull for http services







































































































































































































































































































































