【发布时间】:2022-12-07 12:32:38
【问题描述】:
考虑这两个函数:
const render = (entity) => {
// function body
}
const render = ({
entity,
isAdmin
}) => {
// function body
}
现在假设我想调用这个函数。如果它接受一个解构的对象,我应该以不同的方式传递参数。
render({
name: 'John',
age: 40
})
// or
render({
entity: {
name: 'John',
age: 40
},
isAdmin: true
})
有没有办法让我知道函数是否接受解构对象作为其参数?
请注意,render.length 为这两个函数返回 1。 arguments 对我没有帮助,因为它可以访问里面功能,而不是它之外。
【问题讨论】:
-
是的,使用 Typescript 或禁止使用 Typescript,请阅读文档。否则,不
标签: javascript