《Why use Node.js》 【本字幕由ACELY 整理&转码】 What is node and why would you want to use it for your next project?
Let's have a look at where node came from and what it can do for you.
First of all, node is just JavaScript without a browser.
I'm going to type node here on the
command line, because I already have node installed.
And from here we get the command prompt.
And i'm just going to type console dot log and
I'm going to pass hello in as a string.
Then I'm just going to close
the parenthesis there and add a semi colon.
And then when I press return, it's going to show me hello and undefined.
We can run pretty much any standard JavaScript
here and we're not using a web browser.
Now node wasn't just built from scratch, it came from another project.
Node is actually based of the V8 JavaScript run time from Google Chrome.
So just as we typed in console log there on the command line we can do it here
in the web browser.
And I'm going to pass in hello as a string and close it.
And again we're getting hello and undefined as the output.
So it's the same engine that's running from Google Chrome.
Another reason to use node is that you can use
JavaScript for both your front end and your back end code.
This is one of the packages that's available for node.
It's jquery.
It's something that you're probably all ready familiar with.
And in this case
you can actually use jquery in the back end
as well as the front end of your website.
Another reason to use node, is that it allows you to
use the same JavaScript on the front end as the back end.
Among other features this package called browserify allows you to bundle javascript
from the back end and serve it to your front end application.
And then finally another reason to use node
is that it has native support for evented programming.
The way
node js handles evented programming makes it helpful for
handling things like streams and sockets and very large files.
Node makes it possible for you to take advantage of
everything Javascript has to offer without being tied to a browser.
【本字幕由 CGSUB.COM 独家制作发布】 -----欢迎加入群号：214645753----- In the next video, we'll look at
several different ways of obtaining and installing node.