Skip to content

Commit afa0e2e

Browse files
committed
docs(oop): edit bom
1 parent 4871a73 commit afa0e2e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/oop/prototype.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ function StringBuilder() {
510510
}
511511
```
512512

513-
上面代码中,`buffer`是模块的私有变量。一旦生成实例对象,外部是无法直接访问`buffer`的。但是,这种方法将私有变量封装在构造函数中,违反了构造函数与实例对象相分离的原则。并且,非常耗费内存。
513+
上面代码中,`buffer`是模块的私有变量。一旦生成实例对象,外部是无法直接访问`buffer`的。但是,这种方法将私有变量封装在构造函数中,导致构造函数与实例对象是一体的,总是存在于内存之中,无法在使用完成后清除。这意味着,构造函数有双重作用,既用来塑造实例对象,又用来保存实例对象的数据,违背了构造函数与实例对象在数据上相分离的原则(即实例对象的数据,不应该保存在实例对象以外)。同时,非常耗费内存。
514514

515515
```javascript
516516
function StringBuilder() {

0 commit comments

Comments
 (0)