ES6形参默认值

 形参的默认值----当不传入参数的时候默认使用形参里的默认值

   function Point(x = 1,y = 2) {
    this.x = x;
    this.y = y;
    }
复制代码
 //定义一个点的坐标
    function Point(x=12, y=12) {
        this.x = x;
        this.y = y;
    }
    let point = new Point(25, 36);
    console.log(point);
    let p = new Point();
    console.log(p);
    let point1 = new Point(12, 35);
    console.log(point1);
复制代码
posted @ 2021-10-07 19:41  Frose  阅读(79)  评论(0)    收藏  举报