JavaScript and node. js
JavaScript with you
Aside from technology, let's talk about you and your relationship with JavaScript first. The main purpose of this chapter is to show you whether it is necessary for you to continue reading the following chapters.
If you're like me, then you're starting to "develop" HTML very early, and that's why you have access to something that's called JavaScript, and for JavaScript you only have basic operations--adding interactivity to your Web pages.
And what you really want is "dry", you want to know how to build a complex web site-so you learn a programming language like PHP, Ruby, Java, and start writing "backend" code.
At the same time, you're always looking at JavaScript, and with the introduction of technologies like Jquery,prototype, you've learned a lot about advanced skills in JavaScript, and you feel that JavaScript is more than just window.open () so simple.
However, these are all front-end technologies, although it's always nice to use jquery when you want to enhance the page, but in the end you're a JavaScript user , not a JavaScript developer .
Then there's the node. JS, the server-side JavaScript, how cool is that?
So, you think it's time to pick up the familiar and unfamiliar JavaScript again. But don't worry, writing a node. js application is one thing; understanding why they write in the way they write means--you have to understand JavaScript. It's a real game this time.
Here's the problem: Since JavaScript is really two, or even three, in existence (from the 90 's as a little toy for DHTML, to front-end technology like jquery, to the current server technology), it's hard to find a " Right "way to learn JavaScript so that when you write a node. js app You feel like you're actually developing it rather than just using it.
Because that's the key: You're already an experienced developer, and you don't want to learn new technology by looking everywhere for solutions, which may be incorrect, and you need to make sure you're learning the technology in the right way.
Of course, there is no shortage of excellent javascript-learning articles. However, sometimes it is not enough to rely on those articles. What you need is guidance.
The goal of this book is to provide you with guidance.
Brief statement
There are very good JavaScript programmers in the industry. And I'm not a part of it.
I am the one described in the previous section. I'm familiar with how to develop back-end web apps, but I'm just a newbie to "real" javascript and node. js. I have only recently learned some advanced JavaScript concepts and have no practical experience.
Therefore, this book is not a book "from Beginner to Mastery", more like a book "from Beginner to Advanced".
If it succeeds, then this book is the tutorial that I started learning about node. js.
Server-side JavaScript
JavaScript is first run in a browser, but the browser simply provides a context that defines what can be done with JavaScript, but does not "say" too much about what the JavaScript language itself can do. In fact, JavaScript is a "complete" language: It can be used in different contexts, and its ability is much more than that of other similar languages.
node. js is actually another context that allows JavaScript code to run in the backend (out-of-browser environment).
To implement JavaScript code running in the background, the code needs to be interpreted and executed correctly. This is how node. js works by using Google's V8 virtual machine, the JavaScript execution environment used by Google's Chrome browser, to interpret and execute JavaScript code.
In addition, there are many useful modules along with node. js that can simplify many repetitive chores, such as outputting strings to a terminal.
As a result, node. JS is actually both a runtime environment and a library.
To use node. js, you first need to install it. For more information on how to install node. js, you can refer directly to the official installation guide. After the installation is complete, continue to read the contents of the book below.
"Hello World"
OK, "nonsense" not much to say, immediately began our first node. js application: "Hello World".
Open your favorite editor and create a helloworld.js file. What we're going to do is to output "Hello world" to stdout, and here's the code to implement the feature:
Console. Log("Hello World");
Save the file and execute it through node. JS:
Node Helloworld.js
Normally, it will output Hello World at the terminal.
Well, I admit that the application is a little boring, so let's get some "dry".
Start of business note-node.js JavaScript and node. js