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();