Basics Flashcards
What are the major benefits of using Node.js?
Open source - Simple and fast - Asynchronous - High scalability - Single threaded - Cross platform
What is the difference between Angular and Node.js
Angular is an open source web application framework. Node.js is a cross platform JavaScript runtime environment.
Angular is written in TypeScript. Node.js is written in JavaScript, C and C++.
Angular is made primarily for building SPA’s while Node.js is used for building fast and scalable server side networking applications.
How does Node.js work?
Node.js is a virtual machine that uses JavaScript as its scripting language and runs on the V8 engine.
It works on a single-threaded event loop and a non-blocking I/O.
By making use of the core module HTTP, Node.js can function as a standalone web server using its HTTP module // Using the core HTTP module, Node.js can create its own web server.
What is a runtime environment?
A software stack reponsible for installing your services’s code (and its dependencies) and running your service.
What is Node.js?
A runtime environment that allows JavaScript to be executed outside the browser, primarily for server-side and command-line applications. Its built on Chrome’s V8 JavaScript engine.
What’s the difference between req.params and req.query?
These are properties that are passed through in requests made to an endpoint or to the middleware.
req.params is any param we defined like this /books/:id which will be accessible through req.params.id
req.query is everything that comes after the question mark in an URL. These are key-value pair properties. /books?category=adventure
What is body-parser and what does it do?
Library that parses HTTP body requests from string to JSON format.
Takes the body from a POST request and transforms it into JSON.
What security mechanisms are there in Node.js?
A powerful library called Helmet that’s used primarily in Express.js applications. It adds headers to responses to ensure that the web standards regarding security are met.
What is a framework?
Frameworks are tools that aim to simplify the development of large applications by providing many built-in and reusable libraries, classes, functions, etc.
Examples: Django, Spring, Express.js and .NET
Node.js is the runtime for JavaScript. What other runtimes are there?
JVM for Java, CPython for Python, CLR for C#
What do runtime environments do?
Memory management and converting high level code to machine code (JavaScript engine)
I/O operations through the event loop and libuv or WebAPI’s in JavaScript
How Node is a runtime environment on the server side?
Every browser has a JavaScript engine built in (most popular is Chrome V8). Node takes the V8 engine and wraps it inside Node.js to enable the execution of JavaScript outside the browser.
What is the difference between Node.js and Express.js?
Node.js is a runtime environment. Express.js is a framework to build web applications.
What are the differences between Client-Side (browser) and Server-Side (Node.js)
The main differences is that the Document, Window, Navigator and Event Objects are present in the browser, and not in Node.js
Also, Request/Response Server/Database Object are present in the Server-Side but not in the Client-Side
Browsers handle the UI and user interactions while the server handles business logic, data storage/access, authentication/authorization, etc.