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 @ 2019-12-09 10:02  distant-遥远  阅读(613)  评论(0编辑  收藏  举报