在默认传参在实际中座中还是用的比较多的。 它可以用来解决,用户没有给定值的时候,默认给一个指定的值。
//es6 function say(a = 4) { console.log(a) } say(); //输出4默认传参 //es5的默认传参 function hello(a) { var a = a || 10; console.log(a) } hello ()