diff --git a/CONTRIBUTORS.svg b/CONTRIBUTORS.svg
index 85dfdbd5..53fd0787 100644
--- a/CONTRIBUTORS.svg
+++ b/CONTRIBUTORS.svg
@@ -3,7 +3,7 @@
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1"
width="740"
- height="52"
+ height="104"
>
@@ -34,5 +34,7 @@
快速浏览 ES2015、ES2016、ES2017、ES2018 及以后的 JavaScript 新特性
原型的语法糖。 请参阅: 类
+javascript 默认字段是公共的(public
),如果需要注明私有,可以使用(#
)
class Dog {
+ #name;
+ constructor(name) {
+ this.#name = name;
+ }
+ printName() {
+ //只能在类内部调用私有字段
+ console.log(`你的名字是${this.#name}`)
+ }
+}
+
+const dog = new Dog("putty")
+//console.log(this.#name)
+//Private identifiers are not allowed outside class bodies.
+dog.printName()
+
+class ClassWithPrivate {
+ static #privateStaticField;
+ static #privateStaticFieldWithInitializer = 42;
+
+ static #privateStaticMethod() {
+ // …
+ }
+}
+
new Promise((resolve, reject) => {
@@ -322,6 +350,10 @@
function foo() {}
foo.name // "foo"
+
function foo(a, b){}
+foo.length // 2
+
module.exports = { hello, bye }
diff --git a/index.html b/index.html
index 62444cb9..3b6686ce 100644
--- a/index.html
+++ b/index.html
@@ -463,6 +463,9 @@
+
+
+