TypeScript自定义函数
来源:互联网 发布:淘宝浏览器崩溃 编辑:程序博客网 时间:2024/05/09 16:42
1、函数参数不可选:
private fun(a){
return a;
}
调用是 console.log( fun( 2 ) );
2、函数参数可选,没有传递的参数取默认值:
private argument( a, b=1, c=1 ){
return a*b*c;
}
//调用
var a = 3;
console.log( "参数一个 " + this.argument( a ) );
console.log( "参数二个 " + this.argument( a, 2 ) );
console.log( "参数三个 " + this.argument( a, 2, 3 ) );//输出结果参数一个 3参数二个 6参数三个 18
3、在TypeScript方法里面使用function
//在函数里面不能识别this因此要用self来代替this的作用
var self = this;
function setInfo(){
console.log( );
}
//调用
setInfo();
0 0
- TypeScript自定义函数
- TypeScript函数
- 函数式 TypeScript
- TypeScript 方法/函数
- TypeScript函数类型
- TypeScript 函数使用整理
- Typescript的函数的使用
- Typescript(2) 函数新特性
- TypeScript学习笔记之函数
- typescript promise异步函数操作
- 《揭秘Angular 2》-Typescript 函数
- typescript
- TypeScript
- typeScript
- typescript
- TypeScript
- TypeScript
- typescript
- 趣解进程与线程
- 修复SharePoint 2013 Search 拓扑错误
- 股票学习(K线)
- ios开发—利用xcode tabbed模块快速开发标签栏应用
- struct timeval 和 struct timespec
- TypeScript自定义函数
- maven学习(二)——archetype
- 找到单项链表中间那个元素,如果有两个则取前面一个
- iOS开发——Xcode6 创建Empty Application
- zoj 月赛
- Objective-C字符串处理
- iOS中的基本 UI 控件的使用
- objective-c 多参数方法的定义与调用
- 树莓派解码海康摄像机丢包现象解决