gpt4 book ai didi

javascript - 在javascript中导出默认值

转载 作者:搜寻专家 更新时间:2023-11-01 00:16:53 25 4
gpt4 key购买 nike

我正在学习如何使用 express 和 mongoose 创建 restful api 的教程。

除了这里的这一点,我什么都明白了

import mongoose from 'mongoose';
import config from './config';

export default callback => {
// connect to the database
let db = mongoose.connect(config.mongoUrl);

// callback db
callback(db);
}

我明白它的用途是什么以及如何调用它。令我困惑的是 callback(db) 部分。

这是内置函数还是以某种方式调用自身?

最佳答案

这是一个单参数箭头函数,查看mdn上的描述

// Parentheses are optional when there's only one parameter:
(singleParam) => { statements }
singleParam => { statements }

MDN source

关于javascript - 在javascript中导出默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42846104/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com