I just started learning JavaScript and Node. Since coming from Python background few things seems awkward. For example to create a server in Express we will use:
const express = require("express");
const app = express();
...
where it says
/**
* Creates an Express application. The express() function is a top-level function exported by the express module.
*/
I don't understand why express()
is a function. If the same thing should be done in Python, it will be done like:
from flask import Flask
app = Flask(__name__)
where it says
First we imported the Flask class. An instance of this class will be our WSGI application.
Next we create an instance of this class. The fi...
And this is my general understanding about programming. Most of the time we import some class from a library and make one object and after that, we manipulate its methods. In javascript I find it confusing with function, constructor function, etc. Is a constructor function the same as a class?