如何记录在函数参数中解构的函数参数?
/**
* Function deconstructs argument and do stuff.
* @param {} *** what should i do here? ***
*/
function someFunction({ key1, key2, key3 }) {
// do function stuffs
}
答案 0 :(得分:13)
如果参数在没有显式名称的情况下被解构,您可以为对象提供一个合适的参数并记录其属性。
记录解构参数
/** * Assign the project to an employee. * @param {Object} employee - The employee who is responsible for the project. * @param {string} employee.name - The name of the employee. * @param {string} employee.department - The employee's department. */ Project.prototype.assign = function({ name, department }) { // ... };