Skip to content

"Class基本语法"一节中,对类字段特性的描述 #1185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xiaoyan13 opened this issue Dec 31, 2023 · 2 comments
Closed

"Class基本语法"一节中,对类字段特性的描述 #1185

xiaoyan13 opened this issue Dec 31, 2023 · 2 comments
Labels
Solved Problem solved

Comments

@xiaoyan13
Copy link

Class 字段一小节中,描述了一个特性:

”类字段重要的不同之处在于,它们会在每个独立对象中被设好,而不是设在 User.prototype“。

无论使用类字段、在 constructor 中使用 this 赋值、还是直接使用构造函数 +new,属性设置都是在对象中的,而非在构造函数的prototype(或对象的__proto__)。该句话存在误导性。

@xiaoyan13
Copy link
Author

作者想表达应该是:相对于类中的方法(它们会挂到函数的prototype上),使用带”=“的类字段,会挂到每个实例上而非对象原型上。

@leviding
Copy link
Member

已更新为:类字段的重要区别在于,它们会被挂在实例对象上,而非 User.prototype9f949bf

你看怎么样,此 issue 暂时关闭,如有后续提议,欢迎 reopen 或新建一个 issue,或者直接提 pull request

@leviding leviding added the Solved Problem solved label Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Solved Problem solved
Projects
None yet
Development

No branches or pull requests

2 participants