es6 function parameters (extended)

function show(a,b,...args)
{
alert(a);
alert(b);
alert(args);}
show(12,15,8,9,10);

Parameter expansion

  1. args must be last
  2. ... collecting the remaining parameters
  3. ... to expand the array (the contents of the array write up)
let arr=[1,2,3];
show(...arr);
//show(1,2,3);
function show(a,b,c)
{
		 alert(a);
   	 	alert(b);
    	alert(c);
}

The default parameters

 function show(a,b=5,c=12)
    {
    		console.log(a,b,c);
    }
show(99,19,88);//99,19,88
show(99,19);//99,19,12
show(99);//99,5,12

Guess you like

Origin blog.csdn.net/weixin_44769592/article/details/91446451