type-tls
Version:
type-tls 封装了与类型相关的工具,比如:获取数据的类型 或 类型名字、判断数据的类型 等
63 lines (32 loc) • 1.18 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [type-tls](./type-tls.md) > [isAnonymousFunction](./type-tls.isanonymousfunction.md)
## isAnonymousFunction() function
判断是否是匿名函数
**Signature:**
```typescript
export declare function isAnonymousFunction(fun: Function): boolean;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
fun
</td><td>
Function
</td><td>
</td></tr>
</tbody></table>
**Returns:**
boolean
## Remarks
判断函数在被定义时是否是通过匿名函数来定义的。 匿名函数是指声明函数时没有写名字的函数。 注意:即使是匿名函数,函数对象上的 name 属性也可能是有值的,因为 js解析器 会自动将 函数表达式函数变量的名字作为匿名函数的名字,如下:
```ts
var funName = function(){};
```
其中的匿名函数对象的 name 属性的值会是 `funName`
如果 函数对象上的 name 属性的值为 `""`<!-- -->,函数一定是匿名函数。