express实例的一些判断方法 Posted on 2021-07-06 Edited on 2023-03-01 In nodejs , node资料 由于express实例不是用new的方式创建,就没办法使用instanceof运算符来判断,但是每个app实例都包含了express.application中的所有方法,就只要判断其中方法是相同的就能知道它是一个app实例。 1234const express = require('express');let app = express();console.log(express.application.use === app.use);//true 路由也是一样的。 1234const express = require('express');let route = require('express').Router();console.log(route.use===express.Router.use);//true