The code is easy to read and anyone who is familiar with Javascript (or reading comments on code) can understand how it works. However, there are many abstractions here (thank you, please express). It seems surprising, even if it is more than that seen in other frameworks. We are also creating a start () function that serves as the primary function for running our server. Internally, we are creating a handleRequest that functions as a callback function - you guessed it - it handles the request passed from the server. Instantiate this server with http.createServer and set the port to listen on. listen (3000)
The callback function is part of the so-called "asynchronous" operation of Javascript. Asynchronous operations are performed in a different order than that listed in the program. Javascript has functions to handle functions in this way, so if they are written correctly, they will not be "block" functions. This need usually arises in programs that request data retrieval over the network. Since these requests require a nonzero amount of time, Javascript must wait for data to be returned to perform an operation on it. If the program continues without waiting, an error occurs from an undefined variable or an empty object.
Have you used windows or document host objects? Window objects and document objects are not actually part of the JavaScript core language. They are Web APIs provided by browsers that act as a JavaScript hosting environment. For server-side, the JavaScript runtime is Node.js. Node related host objects such as file system, process, request are in Node.js. This version of ECMAScript changed the name from ES 6 to ES 2015 as Ecma International decided to convert to the annual version ECMAScript in 2015. As a result, Ecma International also began to name the new version of the ECMAScript specification based on the released year. That is, ES 6 and ES 2015 are two different names.