Home > Web Front-end > JS Tutorial > body text

What is MEAN? What does MEAN mean in JavaScript programming? _node.js

WBOY
Release: 2016-05-16 16:25:57
Original
2086 people have browsed it

Some time ago I saw an article mentioning the word MEAN. What is MEAN?

In fact, MENA is the abbreviation of MongoDB (non-relational database) Express (template engine) AngularJS (MVC javascript library) NodeJS (server script).

Together they construct a full-stack development tool for modern web applications based on JavaScript.

MongoDB:

It is a powerful, flexible and scalable data storage method.

It extends many useful features of relational databases, such as auxiliary indexes, range queries, and sorting, its built-in support for MapReduce-style aggregations and support for geospatial indexes.

It replaces the concept of traditional database row with a document model. The so-called document model is actually an array object.

Let’s take a look at the document model:

{“_id” : 1 , “greeting” : “hello, world!” , “foo” : 3}

Each document will have an _id field. The document model represents a record in the database, including the fields greeting, foo and _id;

Express:

Regarding the last engine Express, I would like to describe it in one sentence:

is a simple and flexible node.js Web application framework that provides a series of powerful features to help you create various Web applications.

Rich HTTP tools and middleware from the Connect framework are readily available, making it fast and easy to create robust and friendly APIs

Express does not re-abstract the existing features of node.js, we just extend the functions required by web applications on top of it

AngularJS:

AngularJS is a js library developed by google. It is an MVC script library like backone.

The first lesson of almost every language is about hello world. As usual, we will also do one:

Copy code The code is as follows:







Hello {{'World'}}!


declares that the page uses angularJS. When the page is loaded, the tag ng-app tells AngularJS to process the entire HTML page and guide the application.
This example prints hello world on the page. Some people wonder why hello world is so complicated.

In fact, the content in {{}} is a form of data binding. After reading the next example, you will know its power.

Let’s look at the next example:

Copy code The code is as follows:







Your name:


Hello {{yourname || 'World'}}!


Open this page in the browser, and then try to enter random characters in the input box. You will find that the entered characters are immediately updated and displayed in the greeting. Isn't it amazing?

’s thoughts. Any changes to the input box are immediately reflected in the model variables (one direction), and any changes to the model variables are immediately reflected in the greeting text (the other direction).

There are a few important things to note about this example:

1. The text input command is bound to a model variable called yourname.

2. Double curly brace tag adds yourname model variable to the greeting text.

3. You don’t need to register an additional event listener or add event handler for this application!

NodeJS

is a high-performance server js platform developed by Ryan Dahl.

It is developed based on the V8 engine. The V8 engine is a javascript engine developed by Google, not the car's V8 engine - it is a high-performance engine, and its performance far exceeds that of other scripting languages.

nodeJS uses asynchronous I/O communication method, which is very similar to AJAX:

Copy code The code is as follows:

$.post("url", {title:"post request"}, function(data){
console.log("Response received");
})
console.log("End of sending ajax");

Nodejs request method:

Copy code The code is as follows:

var fs = require('fs');
fs.readFile("/path", function(err, file){
console.log("Reading file completed");
});
console.log("Initiate reading file");

Let’s look at the following example:

When two requests are executed at the same time, the total time consuming depends on the one that takes the most time, not the sum of the time consuming of the two requests, because they are both parallel.

Copy code The code is as follows:

//First request
var fs = require('fs');
fs.readFile("/path1", function(err, file){
console.log("Reading file 1 completed");
});
//Second request
fs.readFile("/path2", function(err, file){
console.log("Reading file 2 completed");
});
console.log("Initiate reading file");

Another reason for the high performance of nodejs is that it is event-driven:

Node introduces events from the front-end browser to the back-end, cooperates with asynchronous I/O, and exposes event points to business logic.

The event generation method has the advantages of being lightweight, loosely coupled, and only focusing on things.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!