The app.delete() function is used to define a route that handles HTTP DELETE requests for a specified path. It accepts a path and one or more callback functions that are executed when a matching DELETE request is received.

Syntax:
app.delete(path, callback [, callback ...])Parameters:
- path: The path for which the DELETE request is handled.
- callback: A middleware function or multiple callback functions that handle the request.
Return Value: Returns the Express application instance.
Steps to Install the express module:
Step 1: You can install this package by using this command.
npm install expressStep 2: After installing the express module, you can check your express version in the command prompt using the command.
npm version expressStep 3: After that, you can just create a folder and add a file, for example, index.js. To run this file you need to run the following command.
node index.jsProject Structure:

Example: Below is the example of the app.delete() Function:
const express = require('express');
const app = express();
const PORT = 3000;
app.delete('/user', function (req, res) {
res.send('DELETE request received');
});
app.listen(PORT, function () {
console.log(`Server listening on PORT ${PORT}`);
});
Steps to run the program:
node index.jsConsole Output:
Server listening on PORT 3000Browser Output: Now make a DELETE request to http://localhost:3000/user and you will get the following output:

Example 2: Handling a DELETE Request with a Route Parameter
const express = require('express');
const app = express();
const PORT = 3000;
app.delete('/user/:id', function (req, res) {
res.send(`User ${req.params.id} deleted`);
});
app.listen(PORT, function () {
console.log(`Server listening on PORT ${PORT}`);
});
Steps to run the program:
node index.jsConsole Output:
Server listening on PORT 3000Browser Output: Now make a DELETE request to http://localhost:3000/user/101 and you will get the following output:

Working of app.delete()
- A DELETE route is defined using app.delete().
- Express receives a DELETE request for the specified path.
- Express matches the request with the DELETE route.
- The callback function is executed.
- The callback sends a response to the client.
Use Cases of app.delete()
- Deleting a resource from an application.
- Creating DELETE APIs for RESTful applications.
- Removing users or records from a database.
- Handling resource deletion based on route parameters.
- Implementing delete operations in web APIs.