Approach 2 Using Arrow Function
Arrow functions in JavaScript offer a more streamlined way to write functions, featuring a simplified syntax, implicit return for single expressions, and lexical scoping of the `this` keyword.
Example: A basic route, employs an arrow function for a more succinct syntax. It establishes a route for the root URL and delivers the “Hello, World!” response in just one line.
Javascript
const express = require( 'express' ); const app = express(); app.get( '/' , (req, res) => res.send( '<h1>Hello, World!</h1>' )); app.listen(8000, () => console.log( 'Server listening on port 8000' )); |
Output:
Print hello world using Express JS
In this article, we will learn how to print Hello World using Express jS. Express JS is a popular web framework for Node.js. It provides various features that make it easy to create and maintain web applications.
Contact Us