when I require “express” I need to know if its an object or function

前端 未结 2 781
独厮守ぢ
独厮守ぢ 2021-01-20 23:55

Given my code

const express = require(\"express\")
const app = express()


console.log(typeof app)
console.log(typeof express)

My terminal tell

2条回答
  •  猫巷女王i
    2021-01-21 00:29

    According to the docs, The express() function is a top-level function exported by the express module.

    It is similar like having Class and Object. The variable express that you are declaring is acting as a class, while the variable app is the object of it which is used.

提交回复
热议问题