Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done! You have completed Node.js Basics!
You have completed Node.js Basics!
Preview
In this step, we'll learn about how Node.js lets us write JavaScript programs that work without the browser.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
[MUSIC] 0:00
Hi, I'm Reggie, and I'm an instructor at Treehouse. 0:09
My pronouns are he, him. 0:12
Today we'll learn about the Node.js, JavaScript runtime environment. 0:14
A runtime environment is where code is executed. 0:19
Runtime environments like Node provide access to features of 0:23
the JavaScript language like data types, objects, and functions. 0:26
Plus, they have a built in engine that compiles code, 0:31
translating your code into something that computers can use and understand. 0:34
We often run JavaScript code in a web browser. 0:39
Browsers like Chrome are one example of a runtime environment. 0:43
Browser runtimes can be called front end runtimes. 0:47
While the browser is one of the most common JavaScript runtime environments, 0:51
there are other non browser environments Node.js being the most popular. 0:55
Instead of using the browser, Node is used for backend, or server-side JavaScript. 1:00
Dynamic web applications can be thought of as restaurants. 1:07
While web applications have a browser client for users to interpret and 1:10
interact with, restaurants have a menu for guests to understand their offerings and 1:14
make orders. 1:18
Servers, and I mean restaurant servers, take the guests order, 1:20
pass it to the kitchen, and return with the food. 1:25
We can think of a server in this example as an application programming interface, 1:30
or a way for programs to communicate. 1:34
The kitchen in this example, is the back end of the application. 1:38
They take a request from a client and return the requested resources or food. 1:42
Backend JavaScript is often used to manage data or interact with other applications. 1:48
Node can be used both to make front end applications dynamic, 1:53
and it can be used on its own. 1:57
Before Node developers had to use other languages like Python to manage data, 2:00
authenticate users, and deliver personalized experiences. 2:05
All JavaScript runtime environments use the standard built in objects that 2:09
are part of the JavaScript programming language. 2:13
These are called native objects, and are often referred to as global objects. 2:17
Different runtime environments have unique objects that allow JavaScript code to 2:23
execute in that specific environment. 2:27
These are called host objects, and they're supplied to JavaScript by the environment. 2:31
They're only available in that environment. 2:36
The browser, for example, provide the window object for accessing the DOM. 2:39
This allows us to manipulate the page using JavaScript. 2:45
Node.js provides a different set of host objects. 2:48
For example, host objects like protocols for requesting data, reading files, 2:52
and others are available to JavaScript to allow it to run outside of the browser. 2:57
Throughout the course, you'll learn more about some of Node's host objects and 3:03
how to use them in your programs. 3:07
Node is based on Google Chrome's V8 open source JavaScript engine, and 3:09
it comes equipped with its own tools. 3:13
The V8 engine is what compiles JavaScript and handles memory. 3:17
A main benefit of Node is its non blocking, 3:21
asynchronous execution of JavaScript code. 3:24
In other words, it can begin executing multiple operations at once without 3:28
waiting for one process to complete before moving on to the next. 3:32
To better explain, I'll use my favorite kind of example, one about food. 3:37
Think of the Node environment and 3:42
its JavaScript engine as the kitchen of your favorite restaurant. 3:44
A busy kitchen accepts many food orders, often at the same time. 3:48
The kitchen uses its resources or 3:53
ingredients to prepare each order and deliver it to the customer. 3:55
A typical restaurant kitchen can receive an order from one customer and 3:59
start it while accepting another. 4:03
They can begin work on one task, 4:06
then another without being blocked by other tasks. 4:08
This non blocking activity makes the process of preparing food orders faster 4:12
and more efficient. 4:17
Imagine if the restaurant kitchen only accepted one order at a time and 4:19
couldn't start another order until the last was finished. 4:22
Being blocked by task after task would likely result in long wait times and 4:26
bad reviews. 4:32
Similar to a fast and efficient restaurant kitchen, 4:33
the Node runtime environment can handle multiple tasks at the same time. 4:36
Nodes non-blocking capabilities allow developers to build real time, 4:41
multi-user apps that handle many users, events, and data requests at once. 4:47
Because of these capabilities, Node apps can easily scale or 4:54
be built to serve more people. 4:58
Netflix uses Node to stream videos to millions of users. 5:01
Companies like PayPal and Capital One have increased the speed of their 5:05
transactions when they went from Java to Node. 5:09
To accommodate millions of job seekers, 5:12
LinkedIn mobile platform is built with Node.js. 5:15
NASA even uses Node to reduce the time it takes to gather information from 5:18
spacesuits. 5:23
In this course, 5:24
we will build two command line applications to get familiar with Node.js. 5:25
One to retrieve Treehouse student profile information, and one to search for 5:29
dictionary definitions. 5:34
Each app will retrieve information from the web and print it to the console. 5:36
These apps will help you get acquainted with some of the features of Node and 5:41
find out why you might want to use it in your projects. 5:44
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up