Objects
Class declarations are not hoisted like functions. This means you can use a function before declaring it, but you cannot use a class before declaring it.
A constructor is like a recipe for creating something in programming.”This” is like saying, “I’m talking about this thing right now.” It helps you work with the thing you’re making using the recipe.
In Express, routing refers to the process of defining how an application responds to different HTTP requests (like GET or POST) and URLs. It’s a way to map specific URLs (routes) to functions or code that should be executed when a client (e.g., a web browser) sends a request to that URL
A route path determines the URL pattern, while a route method specifies the HTTP method used to trigger a specific route handler. Together, they help your web application decide how to handle different types of requests at different URLs.
In summary, you add next as a parameter to route handlers and middleware when you want to control the flow of the request-response cycle. If next is passed to your middleware as a parameter, you can use it to decide whether to continue to the next middleware or route handler, or to handle errors and send responses as appropriate.
An Express Router is a feature in the Express.js web application framework that allows you to organize and modularize your routes and middleware in a more structured and maintainable way. They are useful when building larger web applications that require structuring routes and middleware logically to keep your code organized and maintainable.
Import Express: `const express = require(‘express’);
Create the Router: const router = express.Router();
Define Routes and Middleware:
```router.get(‘/’, (req, res) => { res.send(‘This is the main page.’); });
router.get(‘/about’, (req, res) => { res.send(‘About us page.’); }); ```
Route middleware in Express is used to add custom functionality to routes. It can handle tasks like authentication, validation, logging, error handling, and more. This modular approach helps keep route handlers clean and organized, improving code maintainability and readability.
One of my goals is to get better at CRUD, as it’s something that I struggled with during my final 301 project. In general, I need to learn more about backend developement alltogether.