当前位置:网站首页>Use between nodejs modules
Use between nodejs modules
2022-04-23 16:58:00 【Endless cake】
practice
Separately build A,B,C Three independent js modular .
A Module implementation summation
B Module implementation average
C Module reference B modular , At the same time, complete the process of first summing and then averaging
A modular
//eval() Function to evaluate a string , And execute the JavaScript Code .
module.exports={ // Declare the module component first
sum(...arg){ // use ES6 Extension operator , Put all received parameters into a set
return eval(arg.join('+')) // Connection string , And calculate
}
}
B modular :
// First introduce A modular
let A = require('./a') // Be sure to add. ./ Suffixes can be omitted
module.exports={ // Declare the module component first
avg(...arg){ //( here arg Will be C An array passed from the component )
// Expand each item in an array through the expansion operator , Pass them on to sum, Then divide by the length of the array
return A.sum(...arg) / arg.length
}
C modular :
let B = require('./b')
console.log(B.avg(12,23,34,45,56,67,78,89))
Then execute directly through the command line C.js
版权声明
本文为[Endless cake]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230554520133.html
边栏推荐
- How to build tiktok user trust and drive fan growth
- 手写事件发布订阅框架
- Use case execution of robot framework
- How vscode compares the similarities and differences between two files
- Bytevcharts visual chart library, I have everything you want
- Pseudo Distributed installation spark
- VLAN advanced technology, VLAN aggregation, super VLAN, sub VLAN
- BUG_ me
- Rtklib 2.4.3 source code Notes
- English | day15, 16 x sentence true research daily sentence (clause disconnection, modification)
猜你喜欢
Path environment variable
Use case labeling mechanism of robot framework
The new MySQL table has a self increasing ID of 20 bits. The reason is
面试百分百问到的进程,你究竟了解多少
文件操作《二》(5000字总结篇)
Milvus 2.0 質量保障系統詳解
ByteVCharts可视化图表库,你想要的我都有
STM32__ 03 - beginner timer
[pimf] openharmony paper Club - what is the experience of wandering in ACM survey
Node access to Alipay open platform sandbox to achieve payment function
随机推荐
CentOS MySQL multi instance deployment
Interface document yaml
Knowledge points and examples of [seven input / output systems]
聊一聊浏览器缓存控制
Document operation II (5000 word summary)
Deepinv20 installation MariaDB
Rtklib 2.4.3 source code Notes
Calculation formula related to tolerance analysis
loggie 源码分析 source file 模块主干分析
Lock lock
如何建立 TikTok用户信任并拉动粉丝增长
Selenium IDE and XPath installation of chrome plug-in
5-minute NLP: text to text transfer transformer (T5) unified text to text task model
自定义my_strcpy与库strcpy【模拟实现字符串相关函数】
RTKLIB 2.4.3源码笔记
Camtasia2022软件新增功能介绍
Detailed explanation of Milvus 2.0 quality assurance system
Lock锁
How to build tiktok user trust and drive fan growth
网络安全之渗透靶场实战详解