原型对象创建方法案例 javascript 具体实现步骤如这个yuan代码有吗?

#原型对象创建方法案例
javascript
具体实现步骤如下:

a) 创建一个构造函数Clothes()。

b) 基于Clothes()新增2个对象clothes1、clothes2。

c) 使用prototype给构造函数添加type属性。

d) 使用prototype属性,给构造函数Clothes()添加Clothes_fun方法。

e) 在页面中输出结果。
yuan代码有吗?

我按照步骤写了下


// a) 创建一个构造函数Clothes()
      function Clothes() {}

      // b) 基于Clothes()新增2个对象clothes1、clothes2
      let clothes1 = new Clothes()
      let clothes2 = new Clothes()

      // c) 使用prototype给构造函数添加type属性
      Clothes.prototype.type = 'type'

      // d) 使用prototype属性,给构造函数Clothes()添加Clothes_fun方法
      Clothes.prototype.Clothes_fun = function() {
        console.log('Clothes_fun')
      }

      // e) 在页面中输出结果
      document.write(clothes1 + '<br>')
      document.write(JSON.stringify(clothes2))

      console.log('clothes1', clothes1)
      console.log('clothes2', clothes2)