3.2. NodeJS Basics: JavaScript Fundamentals

Página 5

3.2 NodeJS Basics: JavaScript Basics

NodeJS is a server-side application development platform based on Google's V8 JavaScript Engine interpreter. It was created with a focus on optimizing the construction of scalable and high-performance applications, through a non-blocking and event-oriented I/O model. However, before diving into the NodeJS universe, we need to understand some basic concepts of JavaScript, the language NodeJS is based on.

JavaScript

JavaScript is a high-level, dynamic, interpreted programming language that was initially designed to add interactivity to web pages. Over the years, JavaScript has evolved and today it is used not only on the client side (front-end) but also on the server side (back-end), thanks to platforms like NodeJS.

Variables and data types

In JavaScript, you can declare variables using the keywords "var", "let", and "const". Each has its own scope and rules of use. JavaScript is a dynamically typed language, which means that the data type of a variable can change during code execution. Data types in JavaScript include Number, String, Boolean, Object, Undefined, and Null.

Functions

Functions in JavaScript are blocks of code that can be defined and called by name. Functions can take arguments and return a value. In JavaScript, functions are first-class objects, which means they can be passed as arguments to other functions, returned as values ​​from other functions, assigned to variables, or stored in data structures.

Objects and Arrays

Objects in JavaScript are collections of key-value pairs. Keys are strings and values ​​can be any data type. Arrays are special objects that represent lists of values.

NodeJS

Now that we have a basic understanding of JavaScript, we can start exploring NodeJS. NodeJS allows us to use JavaScript on the server side, that is, we can create complete web applications using only JavaScript.

Event Loop and non-blocking I/O

The most distinctive feature of NodeJS is its non-blocking I/O model. In many programming languages, I/O operations (such as file reading and writing, database access, HTTP requests) are blocking, which means that code execution is paused until the I/O operation is completed. be completed. In contrast, NodeJS uses a non-blocking I/O model, in which I/O operations are performed in parallel with code execution, through a mechanism called Event Loop.

Modules

NodeJS has an integrated module system, which allows you to organize the code in separate files and reuse the code in different parts of the application. Each file in NodeJS is considered a module and can export functions, objects or values ​​to be used in other modules.

NPM

NPM (Node Package Manager) is the package manager for NodeJS. With NPM, you can install and manage third-party packages, which are pieces of code that other people have written that you can use in your applications. NPM is an essential tool for any NodeJS developer.

These are just some of the basics of JavaScript and NodeJS. Throughout the course, we'll explore these and other concepts in more detail, and learn how to apply them in practice to create robust and efficient APIs in NodeJS.

Now answer the exercise about the content:

_Which of the following statements is true about NodeJS?

You are right! Congratulations, now go to the next page

You missed! Try again.

Next page of the Free Ebook:

63.3. NodeJS Basics: NodeJS Basics

Earn your Certificate for this Course for Free! by downloading the Cursa app and reading the ebook there. Available on Google Play or App Store!

Get it on Google Play Get it on App Store

+ 6.5 million
students

Free and Valid
Certificate with QR Code

48 thousand free
exercises

4.8/5 rating in
app stores

Free courses in
video, audio and text