问题遇到的现象和发生背景
为什么class的实例化对象会拷贝类的属性数据,而function的不会。
问题相关代码,请勿粘贴截图
function Person () {
b = 1
function fn () {}
}
Person.prototype.a = 1
var persion = new Person()
console.log(persion);
console.log('---------')
class A {
a = 1
fn () {
}
}
var a = new A()
console.log(a)