当前位置:网站首页>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
边栏推荐
- Detailed explanation of Niuke - Gloves
- Shell script -- shell programming specification and variables
- English | day15, 16 x sentence true research daily sentence (clause disconnection, modification)
- Loggie source code analysis source file module backbone analysis
- VLAN advanced technology, VLAN aggregation, super VLAN, sub VLAN
- Getting started with JDBC
- CentOS MySQL multi instance deployment
- ◰ GL shader handler encapsulation
- Quick install mongodb
- 英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
猜你喜欢

PyTorch:train模式与eval模式的那些坑

Installing labellmg tutorial in Windows

How vscode compares the similarities and differences between two files

How much do you know about the process of the interview

MySQL master-slave replication

Use case execution of robot framework

Detailed explanation of the penetration of network security in the shooting range

English | day15, 16 x sentence true research daily sentence (clause disconnection, modification)

Pycham connects to the remote server and realizes remote debugging

Selenium IDE and XPath installation of chrome plug-in
随机推荐
Error in v-on handler: "typeerror: cannot read property 'resetfields' of undefined"
An essay on the classical "tear down the wall in thinking"
CentOS MySQL multi instance deployment
Knowledge points and examples of [seven input / output systems]
Collect blog posts
org. apache. parquet. schema. InvalidSchemaException: A group type can not be empty. Parquet does not su
Node access to Alipay open platform sandbox to achieve payment function
vscode如何比较两个文件的异同
NVIDIA graphics card driver error
PostgreSQL列存与行存
Mock test
Encapsulating the logging module
Customize my_ Strcpy and library strcpy [analog implementation of string related functions]
Tencent resolves the address according to the IP address
DDT + Excel for interface test
SQL database
Interface document yaml
Shell script -- shell programming specification and variables
Lock lock
Zhimeng dedecms security setup Guide