你用什么函数调用一个对象 [英] What do you call an object with function(s) in it
问题描述
你用什么函数调用一个对象。我记录了一些使用jsdoc返回的函数,我无法坚持使用这种方式。
这就是我要返回的
{fnName:[function]}
或
{fnNameA:[function],fnNameB:[function]}
我的问题以这种方式记录返回值是表达不会将期望属性当作文字 object.fnName
和作为变量函数名称。
如何在jsdocs中表示这个?上面的标准是什么?
我们作为程序员称这种变量为什么?
是否有一个词表达了这一点? / p>
正确的编程答案是Object with methods。这是因为该属性的值是一个函数,不管是否被命名。但应该理解的是,一种方法仅仅是一种功能属性。我们区分它们的原因是与它们进行适当的交互需要稍微不同的签名,从而导致调用。但是,应该注意的是,根据使用情况和可访问性,其他条款可能适用。例如,如果对象被代码使用者使用,则API也可能适用。
重要说明:
如果函数具有名称(属性名称不是函数名称),它们只是命名函数。例如,下面是一个命名函数:
{
prop1:function myFn(){
}
}
What do you call an object with a function in it. I'm documenting some functions that return this with jsdoc and I'm having trouble sticking with one way of conveying this.
This is what I'm returning
{fnName: [function]}
or
{fnNameA: [function], fnNameB: [function]}
My problem documenting the return value this way is conveying not to expect property as literal object.fnName
and as a variable function name.
How do I represent this in jsdocs? Is the above the standard?
What do we as programmers call this kind of variable?
- Object where values are functions
- Object with functions
- Object with function properties
- Object with methods
- Object with named function properties
Is there one word that conveys this?
The proper programming answer is Object with methods. This is because the property's value is a function, whether named or not. But it should be understood that a method is simply a property that is a function. The reason we distinguish them is that interacting with them properly requires a slightly different signature, resulting in an invocation. However, it should be noted that other terms might apply depending upon usage and accessibility. For instance, if the object is to be used by a code consumer, API might also apply.
An important clarification:
They are only named functions if the function has a name (a property name is not a function name). For example, the below would be a named function:
{
prop1: function myFn() {
}
}
这篇关于你用什么函数调用一个对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!