当前位置:网站首页>module. Exports points to problems
module. Exports points to problems
2022-06-21 17:31:00 【Yu'an_ ZhangDe】
Let's start with a question
module.exports === exportsFinal , Shared results , It's always module.exports The object that is pointed to
module.exprots Two directional problems
1、 At the same time point to a
// console.log(exports === module.exports)
const username = 'zs'
module.exports.username = username
exports.age = 20
exports.sayHello = function() {
console.log(' Hello everyone !')
}
// Final , Shared results , It's always module.exports The object that is pointed to
Execution results
![]()

2、module.export Re point to a new object
// In a custom module , By default , module.exports = {}
const age = 20
// towards module.exports Object username attribute
module.exports.username = 'zs'
// towards module.exports Object sayHello Method
module.exports.sayHello = function() {
console.log('Hello!')
}
module.exports.age = age
// Give Way module.exports Point to a new object
module.exports = {
nickname: ' Little black ',
sayHi() {
console.log('Hi!')
}
}Execution results
![]()
Final , Shared results , It's always module.exports The object that is pointed to
边栏推荐
猜你喜欢
![[ros2 basics] Introduction to navigation2 navigation system](/img/7f/ad6af972460d7a78fb28d9b4c24477.png)
[ros2 basics] Introduction to navigation2 navigation system

Vector data download for mainland and global epidemic data, based on geo JSON to SHP

Four areas of telephone memory

How to connect the Internet - FTTH

程序员进修之路

data type

Qt5 knowledge: string list qstringlistmodel

疫情数据对应的大陆和全球的矢量数据下载,基于geojson转shp

Function call model

AS 3744.1标准中提及ISO8191测试,两者测试一样吗?
随机推荐
uni-app框架学习笔记
一些细节
窗帘做EN 1101易燃性测试过程是怎么样的?
Jetpack Compose 的阶段
Calculation of carbon emissions
QT knowledge: using the qgraphicspixmapitem class
#Vscode工具#
Starkrocks Lecture 2 basic operation (1)
Jetpack Compose 管理状态(一)
【mysql学习笔记13】查询语句综合练习
Move Protocol Beta测试版再调整,扩大总奖池
【349期】面试官:如何优雅的自定义 ThreadPoolExecutor 线程池?
RTMP webrtc protocol OpenSSL installation
【Leetcode】297. Serialization and deserialization of binary tree (difficult)
[ros2 basics] Introduction to navigation2 navigation system
[MySQL learning notes 19] multi table query
Research on symmetric TSP Based on MATLAB
变量与指针
clickhouse学习笔记2:基本使用教程
程序员进修之路