From 7ab852ffeafe9bed86ad3bc87e8f67aeb84e327d Mon Sep 17 00:00:00 2001 From: An Hongpeng <79783808+roc-an@users.noreply.github.com> Date: Thu, 14 Oct 2021 09:55:51 +0800 Subject: [PATCH] fix: correct the display of code --- es5/README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/es5/README.md b/es5/README.md index 501953e..5b63c9c 100644 --- a/es5/README.md +++ b/es5/README.md @@ -1169,15 +1169,15 @@ > 为什么?JavaScript 并没有私有属性或私有方法的概念。虽然使用下划线是表示「私有」的一种共识,但实际上这些属性是完全公开的,它本身就是你公共接口的一部分。这种习惯或许会导致开发者错误的认为改动它不会造成破坏或者不需要去测试。长话短说:如果你想要某处为「私有」,它必须不能是显式提出的。 - ```javascript - // bad - this.__firstName__ = 'Panda'; - this.firstName_ = 'Panda'; - this._firstName = 'Panda'; - - // good - this.firstName = 'Panda'; - ``` + ```javascript + // bad + this.__firstName__ = 'Panda'; + this.firstName_ = 'Panda'; + this._firstName = 'Panda'; + + // good + this.firstName = 'Panda'; + ``` - 不要保存 `this` 的引用。使用 Function#bind。