ES6形参默认值19-10-17
2019-10-17 本文已影响0人
你坤儿姐
1.形参的默认值 --当不传入形参的时候默认使用形参的默认值
function Point(x = 0, y = 0){//x = 0, y = 0是设置形参的默认值为0,当没有传入参数的时候默认使用形参是默认值
this.x = x;
this.y = y;
}
let point = new Point(23, 35);
1.形参的默认值 --当不传入形参的时候默认使用形参的默认值
function Point(x = 0, y = 0){//x = 0, y = 0是设置形参的默认值为0,当没有传入参数的时候默认使用形参是默认值
this.x = x;
this.y = y;
}
let point = new Point(23, 35);