1.默认参数

  1. var str = "hello world";
  2. function http(method='get'){ //method
  3. console.log(method);
  4. }
  5. http();
  6. http('post') //method='post'
  1. function http(method:string='get'):void{
  2. console.log(method);
  3. }
  4. http();
  5. http('post')

2.可选参数

  1. function getInfo(name:string,age?:number):void{
  2. console.log(name+age);
  3. }
  4. getInfo('Nihao')